-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
93576df
commit 7980dde
Showing
5 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""The interface to the Groq API.""" | ||
|
||
import os | ||
|
||
from ..framework.provider_interface import ProviderInterface | ||
|
||
|
||
class GroqInterface(ProviderInterface): | ||
"""Implements the ProviderInterface for interacting with Groq's APIs.""" | ||
|
||
def __init__(self): | ||
"""Set up the Groq client using the API key obtained from the user's environment.""" | ||
import groq | ||
|
||
self.groq_client = groq.Groq(api_key=os.getenv("GROQ_API_KEY")) | ||
|
||
def chat_completion_create(self, messages=None, model=None, temperature=0): | ||
"""Request chat completions from the Groq API. | ||
Args: | ||
---- | ||
model (str): Identifies the specific provider/model to use. | ||
messages (list of dict): A list of message objects in chat history. | ||
temperature (float): The temperature to use in the completion. | ||
Returns: | ||
------- | ||
The API response with the completion result. | ||
""" | ||
return self.groq_client.chat.completions.create( | ||
model=model, | ||
messages=messages, | ||
temperature=temperature, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters