jost commited on
Commit
3c3443e
·
verified ·
1 Parent(s): 1503035

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -16
app.py CHANGED
@@ -6,11 +6,13 @@ import json
6
  import time
7
 
8
  togetherai_base_url = "https://api.together.xyz/v1"
 
9
  supported_models = ["mistralai/Mixtral-8x7B-Instruct-v0.1",
10
  "mistralai/Mixtral-8x22B-Instruct-v0.1",
11
  "Qwen/Qwen1.5-1.8B-Chat",
12
  "Qwen/Qwen1.5-14B-Chat",
13
- "Qwen/Qwen1.5-7B-Chat"
 
14
  ]
15
 
16
  multilingual_embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="jost/multilingual-e5-base-politics-de")
@@ -86,21 +88,31 @@ def predict(
86
  prompt = prompt_template.format(impersonation_template=impersonation_template, answer_option_template=answer_option_template, statement=political_statement[3:], rag_template=rag_template)
87
  print(prompt)
88
 
89
- client = OpenAI(base_url=togetherai_base_url, api_key=togetherai_api_key)
90
-
91
- response1 = client.chat.completions.create(
92
- model=model1,
93
- messages=[{"role": "user", "content": prompt},],
94
- temperature=temperature,
95
- max_tokens=1000).choices[0].message.content
96
-
97
- response2 = client.chat.completions.create(
98
- model=model2,
99
- messages=[{"role": "user", "content": prompt},],
100
- temperature=temperature,
101
- max_tokens=1000).choices[0].message.content
 
 
 
 
 
 
 
 
 
 
102
 
103
- return response1, response2, prompt
104
 
105
  def update_political_statement_options(test_type):
106
  # Append an index starting from 1 before each statement
@@ -196,7 +208,7 @@ def main():
196
 
197
  with gr.Row():
198
  with gr.Accordion("Prompt Details", open=False):
199
- prompt_display = gr.Textbox(interactive=False, placeholder="Prompt used in the last submission will appear here.")
200
 
201
  with gr.Tab("Settings"):
202
  with gr.Row():
 
6
  import time
7
 
8
  togetherai_base_url = "https://api.together.xyz/v1"
9
+
10
  supported_models = ["mistralai/Mixtral-8x7B-Instruct-v0.1",
11
  "mistralai/Mixtral-8x22B-Instruct-v0.1",
12
  "Qwen/Qwen1.5-1.8B-Chat",
13
  "Qwen/Qwen1.5-14B-Chat",
14
+ "Qwen/Qwen1.5-7B-Chat",
15
+ "gpt-3.5-turbo-0125"
16
  ]
17
 
18
  multilingual_embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="jost/multilingual-e5-base-politics-de")
 
88
  prompt = prompt_template.format(impersonation_template=impersonation_template, answer_option_template=answer_option_template, statement=political_statement[3:], rag_template=rag_template)
89
  print(prompt)
90
 
91
+ responses = []
92
+ for model in [model1, model2]:
93
+ if model == "gpt-3.5-turbo-0125":
94
+ client = OpenAI(api_key=openai_api_key)
95
+
96
+ response = client.chat.completions.create(
97
+ model=model,
98
+ messages=[{"role": "user", "content": prompt},],
99
+ temperature=temperature,
100
+ max_tokens=1000).choices[0].message.content
101
+
102
+ responses.append(response)
103
+
104
+ else:
105
+ client = OpenAI(base_url=togetherai_base_url, api_key=togetherai_api_key)
106
+
107
+ response = client.chat.completions.create(
108
+ model=model,
109
+ messages=[{"role": "user", "content": prompt},],
110
+ temperature=temperature,
111
+ max_tokens=1000).choices[0].message.content
112
+
113
+ responses.append(response)
114
 
115
+ return responses[0], responses[1], prompt
116
 
117
  def update_political_statement_options(test_type):
118
  # Append an index starting from 1 before each statement
 
208
 
209
  with gr.Row():
210
  with gr.Accordion("Prompt Details", open=False):
211
+ prompt_display = gr.Textbox(show_label=False, interactive=False, placeholder="Prompt used in the last query will appear here.")
212
 
213
  with gr.Tab("Settings"):
214
  with gr.Row():