Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,28 +59,15 @@ def stream_assistant_response(client: OpenAI, model: str, messages: List[Dict[st
|
|
| 59 |
full_response = ""
|
| 60 |
message_placeholder = st.empty()
|
| 61 |
try:
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
presence_penalty=presence_penalty,
|
| 72 |
-
)
|
| 73 |
-
else:
|
| 74 |
-
# For other OpenAI models
|
| 75 |
-
stream = client.chat.completions.create(
|
| 76 |
-
model=model,
|
| 77 |
-
messages=messages,
|
| 78 |
-
stream=True,
|
| 79 |
-
temperature=temperature,
|
| 80 |
-
max_tokens=max_tokens, # Use max_tokens for other models
|
| 81 |
-
frequency_penalty=frequency_penalty,
|
| 82 |
-
presence_penalty=presence_penalty,
|
| 83 |
-
)
|
| 84 |
|
| 85 |
# Iterate through the stream to collect the response.
|
| 86 |
for chunk in stream:
|
|
@@ -109,7 +96,7 @@ def main() -> None:
|
|
| 109 |
st.header("Configuration")
|
| 110 |
|
| 111 |
# Dropdown for model selection.
|
| 112 |
-
model_options = ["gpt-4o", "gpt-4o-mini"
|
| 113 |
default_model = config.ai_model if config.ai_model in model_options else model_options[0]
|
| 114 |
selected_model = st.selectbox(
|
| 115 |
"Model",
|
|
|
|
| 59 |
full_response = ""
|
| 60 |
message_placeholder = st.empty()
|
| 61 |
try:
|
| 62 |
+
stream = client.chat.completions.create(
|
| 63 |
+
model=model,
|
| 64 |
+
messages=messages,
|
| 65 |
+
stream=True,
|
| 66 |
+
temperature=temperature,
|
| 67 |
+
max_tokens=max_tokens, # Use max_tokens for other models
|
| 68 |
+
frequency_penalty=frequency_penalty,
|
| 69 |
+
presence_penalty=presence_penalty,
|
| 70 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
# Iterate through the stream to collect the response.
|
| 73 |
for chunk in stream:
|
|
|
|
| 96 |
st.header("Configuration")
|
| 97 |
|
| 98 |
# Dropdown for model selection.
|
| 99 |
+
model_options = ["gpt-4o", "gpt-4o-mini"]
|
| 100 |
default_model = config.ai_model if config.ai_model in model_options else model_options[0]
|
| 101 |
selected_model = st.selectbox(
|
| 102 |
"Model",
|