keefereuther commited on
Commit
2e6bb31
·
verified ·
1 Parent(s): 69495e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -23
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
- # Different parameter name for o-series models
63
- if model.startswith("o"):
64
- stream = client.chat.completions.create(
65
- model=model,
66
- messages=messages,
67
- stream=True,
68
- temperature=temperature,
69
- max_completion_tokens=max_tokens, # Use max_completion_tokens for o-series models
70
- frequency_penalty=frequency_penalty,
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", "o1", "o3-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",