Spaces:
Sleeping
Sleeping
Update app.py
Browse files5 unmodified lines67891011121314151669 unmodified lines868788899091929394959697989910010110210310410510689 unmodified lines1961971981992002012025 unmodified linesimport timetogetherai_base_url = "https://api.together.xyz/v1"supported_models = ["mistralai/Mixtral-8x7B-Instruct-v0.1","mistralai/Mixtral-8x22B-Instruct-v0.1","Qwen/Qwen1.5-1.8B-Chat","Qwen/Qwen1.5-14B-Chat","Qwen/Qwen1.5-7B-Chat"]multilingual_embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="jost/multilingual-e5-base-politics-de")69 unmodified linesprompt = prompt_template.format(impersonation_template=impersonation_template, answer_option_template=answer_option_template, statement=political_statement[3:], rag_template=rag_template)print(prompt)client = OpenAI(base_url=togetherai_base_url, api_key=togetherai_api_key)response1 = client.chat.completions.create(model=model1,messages=[{"role": "user", "content": prompt},],temperature=temperature,max_tokens=1000).choices[0].message.contentresponse2 = client.chat.completions.create(model=model2,messages=[{"role": "user", "content": prompt},],temperature=temperature,max_tokens=1000).choices[0].message.contentreturn response1, response2, promptdef update_political_statement_options(test_type):# Append an index starting from 1 before each statement89 unmodified lineswith gr.Row():with gr.Accordion("Prompt Details", open=False):prompt_display = gr.Textbox(interactive=False, placeholder="Prompt used in the last submission will appear here.")with gr.Tab("Settings"):with gr.Row():5 unmodified lines678910111213141516171869 unmodified lines88899091929394959697989910010110210310410510610710810911011111211311411511611711889 unmodified lines2082092102112122132145 unmodified linesimport timetogetherai_base_url = "https://api.together.xyz/v1"supported_models = ["mistralai/Mixtral-8x7B-Instruct-v0.1","mistralai/Mixtral-8x22B-Instruct-v0.1","Qwen/Qwen1.5-1.8B-Chat","Qwen/Qwen1.5-14B-Chat","Qwen/Qwen1.5-7B-Chat","gpt-3.5-turbo-0125"]multilingual_embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="jost/multilingual-e5-base-politics-de")69 unmodified linesprompt = prompt_template.format(impersonation_template=impersonation_template, answer_option_template=answer_option_template, statement=political_statement[3:], rag_template=rag_template)print(prompt)responses = []for model in [model1, model2]:if model == "gpt-3.5-turbo-0125":client = OpenAI(api_key=openai_api_key)response = client.chat.completions.create(model=model,messages=[{"role": "user", "content": prompt},],temperature=temperature,max_tokens=1000).choices[0].message.contentresponses.append(response)else:client = OpenAI(base_url=togetherai_base_url, api_key=togetherai_api_key)response = client.chat.completions.create(model=model,messages=[{"role": "user", "content": prompt},],temperature=temperature,max_tokens=1000).choices[0].message.contentresponses.append(response)return responses[0], responses[1], promptdef update_political_statement_options(test_type):# Append an index starting from 1 before each statement89 unmodified lineswith gr.Row():with gr.Accordion("Prompt Details", open=False):prompt_display = gr.Textbox(show_label=False, interactive=False, placeholder="Prompt used in the last query will appear here.")with gr.Tab("Settings"):with gr.Row():
app.py+28-16