Spaces:
Sleeping
Sleeping
Update app.py
Browse filesAdd an llm as available tool.
app.py
CHANGED
|
@@ -4,19 +4,27 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import os
|
| 8 |
+
from huggingface_hub import InferenceClient
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
+
llm_client = InferenceClient(provider="hf-inference", model='Qwen/Qwen2.5-Coder-32B-Instruct')
|
| 13 |
@tool
|
| 14 |
+
def chat_with_an_llm(prompt:str)-> str: #it's import to specify the return type
|
| 15 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 16 |
+
"""An large language model to talk with.
|
| 17 |
Args:
|
| 18 |
+
prompt: the prompt to send to the large language model.
|
|
|
|
| 19 |
"""
|
| 20 |
+
output = llm_client.chat.completions.create(
|
| 21 |
+
messages=[
|
| 22 |
+
{"role": "user", "content": prompt},
|
| 23 |
+
],
|
| 24 |
+
stream=False,
|
| 25 |
+
max_tokens=1024,
|
| 26 |
+
)
|
| 27 |
+
return output.choices[0].message.content
|
| 28 |
|
| 29 |
@tool
|
| 30 |
def get_current_time_in_timezone(timezone: str) -> str:
|