Spaces:
Runtime error
Runtime error
gokaygokay
commited on
Commit
•
726ed91
1
Parent(s):
e22615e
sambanova
Browse files- huggingface_inference_node.py +17 -0
- ui_components.py +2 -1
huggingface_inference_node.py
CHANGED
@@ -8,6 +8,7 @@ from openai import OpenAI
|
|
8 |
|
9 |
huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
|
10 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
|
|
11 |
|
12 |
|
13 |
class LLMInferenceNode:
|
@@ -17,6 +18,10 @@ class LLMInferenceNode:
|
|
17 |
api_key=huggingface_token,
|
18 |
)
|
19 |
self.groq_client = Groq(api_key=groq_api_key)
|
|
|
|
|
|
|
|
|
20 |
|
21 |
def generate(
|
22 |
self,
|
@@ -144,6 +149,18 @@ You are allowed to make up film and branding names, and do them like 80's, 90's
|
|
144 |
)
|
145 |
output = response.choices[0].message.content.strip()
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
else:
|
148 |
raise ValueError(f"Unsupported provider: {provider}")
|
149 |
|
|
|
8 |
|
9 |
huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
|
10 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
11 |
+
sambanova_api_key = os.getenv("SAMBANOVA_API_KEY")
|
12 |
|
13 |
|
14 |
class LLMInferenceNode:
|
|
|
18 |
api_key=huggingface_token,
|
19 |
)
|
20 |
self.groq_client = Groq(api_key=groq_api_key)
|
21 |
+
self.sambanova_client = OpenAI(
|
22 |
+
api_key=sambanova_api_key,
|
23 |
+
base_url="https://api.sambanova.ai/v1",
|
24 |
+
)
|
25 |
|
26 |
def generate(
|
27 |
self,
|
|
|
149 |
)
|
150 |
output = response.choices[0].message.content.strip()
|
151 |
|
152 |
+
elif provider == "SambaNova":
|
153 |
+
response = self.sambanova_client.chat.completions.create(
|
154 |
+
model=model or "Meta-Llama-3.1-70B-Instruct",
|
155 |
+
max_tokens=1024,
|
156 |
+
temperature=0.7,
|
157 |
+
messages=[
|
158 |
+
{"role": "system", "content": system_message},
|
159 |
+
{"role": "user", "content": user_message},
|
160 |
+
],
|
161 |
+
)
|
162 |
+
output = response.choices[0].message.content.strip()
|
163 |
+
|
164 |
else:
|
165 |
raise ValueError(f"Unsupported provider: {provider}")
|
166 |
|
ui_components.py
CHANGED
@@ -131,7 +131,7 @@ def create_interface():
|
|
131 |
|
132 |
# Add new components for LLM provider selection
|
133 |
llm_provider = gr.Dropdown(
|
134 |
-
choices=["Hugging Face", "
|
135 |
label="LLM Provider",
|
136 |
value="Hugging Face"
|
137 |
)
|
@@ -204,6 +204,7 @@ def create_interface():
|
|
204 |
"Groq": ["llama-3.1-70b-versatile"],
|
205 |
"OpenAI": ["gpt-4o", "gpt-4o-mini"],
|
206 |
"Anthropic": ["claude-3-5-sonnet-20240620"],
|
|
|
207 |
}
|
208 |
models = provider_models[provider]
|
209 |
return gr.Dropdown(choices=models, value=models[0])
|
|
|
131 |
|
132 |
# Add new components for LLM provider selection
|
133 |
llm_provider = gr.Dropdown(
|
134 |
+
choices=["Hugging Face", "Groq", "SambaNova", "OpenAI", "Anthropic"],
|
135 |
label="LLM Provider",
|
136 |
value="Hugging Face"
|
137 |
)
|
|
|
204 |
"Groq": ["llama-3.1-70b-versatile"],
|
205 |
"OpenAI": ["gpt-4o", "gpt-4o-mini"],
|
206 |
"Anthropic": ["claude-3-5-sonnet-20240620"],
|
207 |
+
"SambaNova": ["Meta-Llama-3.1-70B-Instruct"],
|
208 |
}
|
209 |
models = provider_models[provider]
|
210 |
return gr.Dropdown(choices=models, value=models[0])
|