Spaces:
Sleeping
Sleeping
Update excel_chat.py
Browse files- excel_chat.py +24 -2
excel_chat.py
CHANGED
|
@@ -21,7 +21,7 @@ def ask_llm(query, input, client_index):
|
|
| 21 |
"content": f"{input}",
|
| 22 |
}
|
| 23 |
]
|
| 24 |
-
systemC = f"You are a helpful assistant. Only show your final response to the **User Query**! Do not provide any explanations or details: \n# User Query:\n{query}."
|
| 25 |
messageC=[
|
| 26 |
{
|
| 27 |
"role": "user",
|
|
@@ -40,12 +40,34 @@ def ask_llm(query, input, client_index):
|
|
| 40 |
messages=messages,
|
| 41 |
model='mixtral-8x7b-32768',
|
| 42 |
)
|
| 43 |
-
elif client_index == "Mistral":
|
| 44 |
client = MistralClient(api_key=os.environ['MISTRAL_API_KEY'])
|
| 45 |
chat_completion = client.chat(
|
| 46 |
messages=messages,
|
| 47 |
model='mistral-small-latest',
|
| 48 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
else:
|
| 50 |
client = anthropic.Anthropic(api_key=os.environ['CLAUDE_API_KEY'])
|
| 51 |
chat_completion = client.messages.create(
|
|
|
|
| 21 |
"content": f"{input}",
|
| 22 |
}
|
| 23 |
]
|
| 24 |
+
systemC = f"You are a helpful assistant. Only show your final response to the **User Query**! Do not provide any explanations or details: \n# User Query:\n{query}."
|
| 25 |
messageC=[
|
| 26 |
{
|
| 27 |
"role": "user",
|
|
|
|
| 40 |
messages=messages,
|
| 41 |
model='mixtral-8x7b-32768',
|
| 42 |
)
|
| 43 |
+
elif client_index == "Mistral Small":
|
| 44 |
client = MistralClient(api_key=os.environ['MISTRAL_API_KEY'])
|
| 45 |
chat_completion = client.chat(
|
| 46 |
messages=messages,
|
| 47 |
model='mistral-small-latest',
|
| 48 |
)
|
| 49 |
+
elif client_index == "Mistral Tiny":
|
| 50 |
+
client = MistralClient(api_key=os.environ['MISTRAL_API_KEY'])
|
| 51 |
+
chat_completion = client.chat(
|
| 52 |
+
messages=messages,
|
| 53 |
+
model='mistral-tiny',
|
| 54 |
+
)
|
| 55 |
+
elif client_index == "Mistral Medium":
|
| 56 |
+
client = MistralClient(api_key=os.environ['MISTRAL_API_KEY'])
|
| 57 |
+
chat_completion = client.chat(
|
| 58 |
+
messages=messages,
|
| 59 |
+
model='mistral-medium',
|
| 60 |
+
)
|
| 61 |
+
elif client_index == "Claude Opus":
|
| 62 |
+
client = anthropic.Anthropic(api_key=os.environ['CLAUDE_API_KEY'])
|
| 63 |
+
chat_completion = client.messages.create(
|
| 64 |
+
model="claude-3-opus-20240229",
|
| 65 |
+
max_tokens=350,
|
| 66 |
+
temperature=0,
|
| 67 |
+
system=systemC,
|
| 68 |
+
messages=messageC
|
| 69 |
+
).content[0].text
|
| 70 |
+
return chat_completion
|
| 71 |
else:
|
| 72 |
client = anthropic.Anthropic(api_key=os.environ['CLAUDE_API_KEY'])
|
| 73 |
chat_completion = client.messages.create(
|