Spaces:
Runtime error
Runtime error
Update chain_app.py
Browse files- chain_app.py +11 -0
chain_app.py
CHANGED
@@ -60,6 +60,14 @@ async def set_starters():
|
|
60 |
)
|
61 |
]
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
@cl.set_chat_profiles
|
64 |
async def chat_profile():
|
65 |
return [
|
@@ -2587,14 +2595,17 @@ async def main(message: cl.Message):
|
|
2587 |
).send()
|
2588 |
|
2589 |
elif chat_profile == 'Yi-1.5-34B':
|
|
|
2590 |
client = InferenceClient(
|
2591 |
"01-ai/Yi-1.5-34B-Chat",
|
2592 |
token=f'{hf_token_llama_3_1}',
|
2593 |
)
|
|
|
2594 |
result = client.chat_completion(
|
2595 |
messages=[{"role": "user", "content": message.content}],
|
2596 |
max_tokens=500,
|
2597 |
)
|
|
|
2598 |
await cl.Message(
|
2599 |
content=result.choices[0].message.content,
|
2600 |
).send()
|
|
|
60 |
)
|
61 |
]
|
62 |
|
63 |
+
|
64 |
+
@cl.step(type="tool")
|
65 |
+
async def tool():
|
66 |
+
# Simulate a running task
|
67 |
+
await cl.sleep(2)
|
68 |
+
|
69 |
+
return "Response from the tool!"
|
70 |
+
|
71 |
@cl.set_chat_profiles
|
72 |
async def chat_profile():
|
73 |
return [
|
|
|
2595 |
).send()
|
2596 |
|
2597 |
elif chat_profile == 'Yi-1.5-34B':
|
2598 |
+
final_answer = await cl.Message(content="").send()
|
2599 |
client = InferenceClient(
|
2600 |
"01-ai/Yi-1.5-34B-Chat",
|
2601 |
token=f'{hf_token_llama_3_1}',
|
2602 |
)
|
2603 |
+
tool_res = await tool()
|
2604 |
result = client.chat_completion(
|
2605 |
messages=[{"role": "user", "content": message.content}],
|
2606 |
max_tokens=500,
|
2607 |
)
|
2608 |
+
|
2609 |
await cl.Message(
|
2610 |
content=result.choices[0].message.content,
|
2611 |
).send()
|