Groq API
1.0.0
Groq API 채팅 어시스턴트는 Groq API를 사용하여 사용자 쿼리 또는 프롬프트에 대한 응답을 생성 할 수있는 채팅 어시스턴트를 만드는 도구입니다. LLM (Large Language Model)을 활용하여 유익하고 상황에 맞는 답변을 제공하여 고객 지원, 정보 검색 및 대화 인터페이스와 같은 다양한 응용 프로그램에 적합합니다.
이 프로젝트를 실행하려면 필요한 종속성을 설치해야합니다. Colab 노트에서 다음 명령을 실행하십시오.
! pip install -q -U langchain langchain_core langchain_groq gradio이 노트를 사용하려면 다음이 필요합니다.
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 가 있는지 확인하십시오.gradio 라이브러리는 챗봇의 인터페이스를 만드는 데 사용됩니다.gradio deploy 사용하여 공간에 배포하는 것을 고려하십시오. 피드백이 있으시면 [email protected]으로 저에게 연락하십시오.