Spaces:
Running
Running
set groq for moonshot
Browse files
app.py
CHANGED
@@ -232,6 +232,9 @@ if not HF_TOKEN:
|
|
232 |
|
233 |
def get_inference_client(model_id, provider="auto"):
|
234 |
"""Return an InferenceClient with provider based on model_id and user selection."""
|
|
|
|
|
|
|
235 |
return InferenceClient(
|
236 |
provider=provider,
|
237 |
api_key=HF_TOKEN,
|
@@ -1030,7 +1033,12 @@ This will help me create a better design for you."""
|
|
1030 |
content = ""
|
1031 |
for chunk in completion:
|
1032 |
# Only process if chunk.choices is non-empty
|
1033 |
-
if
|
|
|
|
|
|
|
|
|
|
|
1034 |
content += chunk.choices[0].delta.content
|
1035 |
clean_code = remove_code_block(content)
|
1036 |
search_status = " (with web search)" if enable_search and tavily_client else ""
|
|
|
232 |
|
233 |
def get_inference_client(model_id, provider="auto"):
|
234 |
"""Return an InferenceClient with provider based on model_id and user selection."""
|
235 |
+
if model_id == "moonshotai/Kimi-K2-Instruct":
|
236 |
+
provider = "groq"
|
237 |
+
|
238 |
return InferenceClient(
|
239 |
provider=provider,
|
240 |
api_key=HF_TOKEN,
|
|
|
1033 |
content = ""
|
1034 |
for chunk in completion:
|
1035 |
# Only process if chunk.choices is non-empty
|
1036 |
+
if (
|
1037 |
+
hasattr(chunk, "choices") and chunk.choices and
|
1038 |
+
hasattr(chunk.choices[0], "delta") and
|
1039 |
+
hasattr(chunk.choices[0].delta, "content") and
|
1040 |
+
chunk.choices[0].delta.content is not None
|
1041 |
+
):
|
1042 |
content += chunk.choices[0].delta.content
|
1043 |
clean_code = remove_code_block(content)
|
1044 |
search_status = " (with web search)" if enable_search and tavily_client else ""
|