Groq API
1.0.0
Der COQ -API -Chat -Assistent ist ein Tool, das die CROQ -API verwendet, um einen Chat -Assistenten zu erstellen, der Antworten auf Benutzeranfragen oder -Eingabeaufforderungen generieren kann. Es nutzt große Sprachmodelle (LLMs), um informative und kontextbezogene Antworten zu geben, sodass sie für eine Vielzahl von Anwendungen wie Kundensupport, Informationsabruf und Konversationsschnittstellen geeignet sind.
Um dieses Projekt auszuführen, müssen Sie die erforderlichen Abhängigkeiten installieren. Führen Sie den folgenden Befehl in Ihrem Colab -Notizbuch aus:
! pip install -q -U langchain langchain_core langchain_groq gradioUm dieses Notebook zu verwenden, müssen Sie Folgendes haben:
from google . colab import userdata
groq_api_key = userdata . get ( 'GROQ_API_KEY' )
from langchain_groq import ChatGroq
chat = ChatGroq (
api_key = groq_api_key ,
model_name = "mixtral-8x7b-32768"
) from langchain_core . output_parsers import StrOutputParser
chain = prompt | chat | StrOutputParser ()
response = chain . invoke ({ "text" : "Why is the sky blue?" })
print ( response ) import gradio as gr
def fetch_response ( user_input ):
chat = ChatGroq (
api_key = groq_api_key ,
model_name = "mixtral-8x7b-32768"
)
system = "You are a helpful assistant."
human = "{text}"
prompt = ChatPromptTemplate . from_messages (
[
( "system" , system ), ( "human" , human )
]
)
chain = prompt | chat | StrOutputParser ()
output = chain . invoke ({ "text" : user_input })
return output
user_input = "Why is the sky blue?"
fetch_response ( user_input ) iface = gr . Interface (
fn = fetch_response ,
inputs = "text" ,
outputs = "text" ,
title = "Groq Chatbot" ,
description = "Ask a question and get a response."
)
iface . launch ()GROQ_API_KEY haben, um auf die GROQ -API zuzugreifen.gradio -Bibliothek wird verwendet, um eine Schnittstelle für den Chatbot zu erstellen.gradio deploy von Terminal in Betracht ziehen. Wenn Sie Feedback haben, wenden Sie sich bitte an mich unter [email protected]