fix funcs naming
This commit is contained in:
parent
1070ed37ba
commit
696da72adb
@ -6,12 +6,13 @@ import streamlit as st
|
|||||||
|
|
||||||
|
|
||||||
@st.cache_data()
|
@st.cache_data()
|
||||||
def chat_gpt_request(ai_model: str, messages: List[dict]) -> dict:
|
def create_gpt_completion(ai_model: str, messages: List[dict]) -> dict:
|
||||||
openai.api_key = st.secrets.api_credentials.api_key
|
openai.api_key = st.secrets.api_credentials.api_key
|
||||||
logging.info(f"{messages=}")
|
logging.info(f"{messages=}")
|
||||||
completion = openai.ChatCompletion.create(
|
completion = openai.ChatCompletion.create(
|
||||||
model=ai_model,
|
model=ai_model,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
|
# stream=True,
|
||||||
# temperature=0.7,
|
# temperature=0.7,
|
||||||
)
|
)
|
||||||
logging.info(f"{completion=}")
|
logging.info(f"{completion=}")
|
||||||
|
@ -4,7 +4,7 @@ from requests.exceptions import TooManyRedirects
|
|||||||
from streamlit_chat import message
|
from streamlit_chat import message
|
||||||
|
|
||||||
from src.utils.agi.bard import BardChat
|
from src.utils.agi.bard import BardChat
|
||||||
from src.utils.agi.chat_gpt import chat_gpt_request
|
from src.utils.agi.chat_gpt import create_gpt_completion
|
||||||
from src.utils.stt import show_voice_input
|
from src.utils.stt import show_voice_input
|
||||||
from src.utils.tts import show_player
|
from src.utils.tts import show_player
|
||||||
|
|
||||||
@ -55,9 +55,9 @@ def show_chat(ai_content: str, user_text: str) -> None:
|
|||||||
st.markdown(st.session_state.generated[i])
|
st.markdown(st.session_state.generated[i])
|
||||||
|
|
||||||
|
|
||||||
def chat_gpt_conversation() -> None:
|
def show_gpt_conversation() -> None:
|
||||||
try:
|
try:
|
||||||
completion = chat_gpt_request(st.session_state.model, st.session_state.messages)
|
completion = create_gpt_completion(st.session_state.model, st.session_state.messages)
|
||||||
ai_content = completion.get("choices")[0].get("message").get("content")
|
ai_content = completion.get("choices")[0].get("message").get("content")
|
||||||
st.session_state.messages.append({"role": "assistant", "content": ai_content})
|
st.session_state.messages.append({"role": "assistant", "content": ai_content})
|
||||||
if ai_content:
|
if ai_content:
|
||||||
@ -76,7 +76,7 @@ def chat_gpt_conversation() -> None:
|
|||||||
st.error(err)
|
st.error(err)
|
||||||
|
|
||||||
|
|
||||||
def bard_conversation() -> None:
|
def show_bard_conversation() -> None:
|
||||||
try:
|
try:
|
||||||
bard = BardChat(st.secrets.api_credentials.bard_session)
|
bard = BardChat(st.secrets.api_credentials.bard_session)
|
||||||
ai_content = bard.ask(st.session_state.user_text)
|
ai_content = bard.ask(st.session_state.user_text)
|
||||||
@ -95,6 +95,6 @@ def show_conversation() -> None:
|
|||||||
{"role": "user", "content": st.session_state.user_text},
|
{"role": "user", "content": st.session_state.user_text},
|
||||||
]
|
]
|
||||||
if st.session_state.model == "bard":
|
if st.session_state.model == "bard":
|
||||||
bard_conversation()
|
show_bard_conversation()
|
||||||
else:
|
else:
|
||||||
chat_gpt_conversation()
|
show_gpt_conversation()
|
||||||
|
Loading…
Reference in New Issue
Block a user