Synnove commited on
Commit
34e1112
·
verified ·
1 Parent(s): b487e1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -21
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
- client = InferenceClient(
15
- provider="hf-inference",
16
- api_key=os.environ["HF_TOKEN"],
17
- )
18
 
19
- completion = client.chat.completions.create(
20
- model="tiiuae/falcon-rw-1b",
21
- messages=[
22
- {
23
- "role": "user",
24
- "content": "What is the capital of France?"
25
- }
26
- ],
27
  )
28
 
29
- completion = client.chat.completions.create(
30
- model="sarvamai/sarvam-m",
31
- messages=[
32
- {
33
- "role": "user",
34
- "content": "What is the capital of France?"
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 ---