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