Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,29 +9,33 @@ from huggingface_hub import InferenceClient
|
|
9 |
|
10 |
def llm_chat_response(text):
|
11 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
12 |
-
client = InferenceClient(
|
13 |
-
|
14 |
-
|
15 |
-
"role": "user",
|
16 |
-
"content": [
|
17 |
-
{
|
18 |
-
"type": "text",
|
19 |
-
"text": text + str('describe in one line only')
|
20 |
-
} #,
|
21 |
-
# {
|
22 |
-
# "type": "image_url",
|
23 |
-
# "image_url": {
|
24 |
-
# "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
|
25 |
-
# }
|
26 |
-
# }
|
27 |
-
]
|
28 |
-
}
|
29 |
-
]
|
30 |
|
31 |
response_from_llama = client.chat.completions.create(
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
return response_from_llama.choices[0].message['content']
|
37 |
|
|
|
9 |
|
10 |
def llm_chat_response(text):
|
11 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
12 |
+
client = InferenceClient(
|
13 |
+
provider="hf-inference",
|
14 |
+
api_key=HF_TOKEN,)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
response_from_llama = client.chat.completions.create(
|
17 |
+
model="meta-llama/Llama-3.2-11B-Vision-Instruct",
|
18 |
+
messages=[
|
19 |
+
{
|
20 |
+
"role": "user",
|
21 |
+
"content": [
|
22 |
+
{
|
23 |
+
"type": "text",
|
24 |
+
"text": "Describe this image in one sentence."
|
25 |
+
}#,
|
26 |
+
# {
|
27 |
+
# "type": "image_url",
|
28 |
+
# "image_url": {
|
29 |
+
# "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
|
30 |
+
# }
|
31 |
+
# }
|
32 |
+
]
|
33 |
+
}
|
34 |
+
],
|
35 |
+
max_tokens=500,
|
36 |
+
)
|
37 |
+
|
38 |
+
|
39 |
|
40 |
return response_from_llama.choices[0].message['content']
|
41 |
|