Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,30 +11,45 @@ from huggingface_hub import InferenceClient
|
|
11 |
#token = HF_TOKEN
|
12 |
#model_repo_id = chat_completion eller question_answering
|
13 |
|
14 |
-
|
15 |
-
provider="hf-inference",
|
16 |
-
api_key=os.environ["HF_TOKEN"],
|
17 |
-
)
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
{
|
23 |
-
"role": "user",
|
24 |
-
"content": "What is the capital of France?"
|
25 |
-
}
|
26 |
-
],
|
27 |
)
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
# (Keep Constants as is)
|
40 |
# --- Constants ---
|
|
|
11 |
#token = HF_TOKEN
|
12 |
#model_repo_id = chat_completion eller question_answering
|
13 |
|
14 |
+
from smolagent import CodeAgent, LLMFunction
|
|
|
|
|
|
|
15 |
|
16 |
+
llm = LLMFunction.from_huggingface_inference_api(
|
17 |
+
repo_id="google/flan-t5-base", #
|
18 |
+
token="HF_TOKEN "
|
|
|
|
|
|
|
|
|
|
|
19 |
)
|
20 |
|
21 |
+
agent = CodeAgent(llm=llm)
|
22 |
+
response = agent("Translate 'How are you?' to German.")
|
23 |
+
print(response)
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
#----
|
29 |
+
# client = InferenceClient(
|
30 |
+
# provider="hf-inference",
|
31 |
+
# api_key=os.environ["HF_TOKEN"],
|
32 |
+
# )
|
33 |
+
|
34 |
+
# completion = client.chat.completions.create(
|
35 |
+
# model="tiiuae/falcon-rw-1b",
|
36 |
+
# messages=[
|
37 |
+
# {
|
38 |
+
# "role": "user",
|
39 |
+
# "content": "What is the capital of France?"
|
40 |
+
# }
|
41 |
+
# ],
|
42 |
+
# )
|
43 |
+
|
44 |
+
# completion = client.chat.completions.create(
|
45 |
+
# model="sarvamai/sarvam-m",
|
46 |
+
# messages=[
|
47 |
+
# {
|
48 |
+
# "role": "user",
|
49 |
+
# "content": "What is the capital of France?"
|
50 |
+
# }
|
51 |
+
# ],
|
52 |
+
# )
|
53 |
|
54 |
# (Keep Constants as is)
|
55 |
# --- Constants ---
|