Spaces:
Sleeping
Sleeping
File size: 636 Bytes
5de8e05 1fae7a0 5de8e05 9479e69 5de8e05 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import os
import gradio as gr
from langchain_groq import ChatGroq
from langchain.schema import AIMessage, HumanMessage
chat = ChatGroq(temperature=0, model_name="llama3-70b-8192", api_key=os.getenv("GROQ_API_KEY"))
def predict(message, history):
history_langchain_format = []
for human, ai in history:
history_langchain_format.append(HumanMessage(content=human))
history_langchain_format.append(AIMessage(content=ai))
history_langchain_format.append(HumanMessage(content=message))
gpt_response = chat.invoke(history_langchain_format)
return gpt_response.content
gr.ChatInterface(predict).launch() |