Use `huggingface_hub.InferenceClient` instead of `openai` to call Sambanova
#1
by
Wauplin
HF staff
- opened
- app.py +4 -4
- requirements.txt +1 -1
app.py
CHANGED
@@ -5,7 +5,7 @@ from pathlib import Path
|
|
5 |
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
-
import
|
9 |
from dotenv import load_dotenv
|
10 |
from fastapi import FastAPI
|
11 |
from fastapi.responses import HTMLResponse, StreamingResponse
|
@@ -25,9 +25,9 @@ load_dotenv()
|
|
25 |
curr_dir = Path(__file__).parent
|
26 |
|
27 |
|
28 |
-
client =
|
29 |
api_key=os.environ.get("SAMBANOVA_API_KEY"),
|
30 |
-
|
31 |
)
|
32 |
stt_model = get_stt_model()
|
33 |
|
@@ -52,7 +52,7 @@ def response(
|
|
52 |
raise WebRTCError("test")
|
53 |
|
54 |
request = client.chat.completions.create(
|
55 |
-
model="
|
56 |
messages=conversation_state, # type: ignore
|
57 |
temperature=0.1,
|
58 |
top_p=0.1,
|
|
|
5 |
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
+
import huggingface_hub
|
9 |
from dotenv import load_dotenv
|
10 |
from fastapi import FastAPI
|
11 |
from fastapi.responses import HTMLResponse, StreamingResponse
|
|
|
25 |
curr_dir = Path(__file__).parent
|
26 |
|
27 |
|
28 |
+
client = huggingface_hub.InferenceClient(
|
29 |
api_key=os.environ.get("SAMBANOVA_API_KEY"),
|
30 |
+
provider="sambanova",
|
31 |
)
|
32 |
stt_model = get_stt_model()
|
33 |
|
|
|
52 |
raise WebRTCError("test")
|
53 |
|
54 |
request = client.chat.completions.create(
|
55 |
+
model="meta-llama/Llama-3.2-3B-Instruct",
|
56 |
messages=conversation_state, # type: ignore
|
57 |
temperature=0.1,
|
58 |
top_p=0.1,
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
fastrtc[vad, stt]
|
2 |
python-dotenv
|
3 |
-
|
4 |
twilio
|
|
|
1 |
fastrtc[vad, stt]
|
2 |
python-dotenv
|
3 |
+
huggingface_hub
|
4 |
twilio
|