mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-17 19:59:47 +00:00
Add tool calls to groq inference adapter
This commit is contained in:
parent
78912e663b
commit
cf87262e9c
4 changed files with 400 additions and 60 deletions
|
|
@ -7,6 +7,7 @@
|
|||
import warnings
|
||||
from typing import AsyncIterator, List, Optional, Union
|
||||
|
||||
import groq
|
||||
from groq import Groq
|
||||
from llama_models.datatypes import SamplingParams
|
||||
from llama_models.llama3.api.datatypes import (
|
||||
|
|
@ -126,7 +127,14 @@ class GroqInferenceAdapter(Inference, ModelRegistryHelper):
|
|||
)
|
||||
)
|
||||
|
||||
response = self._client.chat.completions.create(**request)
|
||||
try:
|
||||
response = self._client.chat.completions.create(**request)
|
||||
except groq.BadRequestError as e:
|
||||
if e.body.get("error", {}).get("code") == "tool_use_failed":
|
||||
# For smaller models, Groq may fail to call a tool even when the request is well formed
|
||||
raise ValueError("Groq failed to call a tool", e.body.get("error", {}))
|
||||
else:
|
||||
raise e
|
||||
|
||||
if stream:
|
||||
return convert_chat_completion_response_stream(response)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue