Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -1,6 +1,20 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
return message
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain.chat_models import ChatOpenAI
|
2 |
+
from langchain.schema import AIMessage, HumanMessage
|
3 |
+
import openai
|
4 |
import gradio as gr
|
5 |
+
import os
|
6 |
|
7 |
+
os.environ["OPENAI_API_KEY"] = "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" # Replace with your key
|
|
|
8 |
|
9 |
+
llm = ChatOpenAI(temperature=1.0, model='gpt-3.5-turbo-0613')
|
10 |
+
|
11 |
+
def predict(message, history):
|
12 |
+
history_langchain_format = []
|
13 |
+
for human, ai in history:
|
14 |
+
history_langchain_format.append(HumanMessage(content=human))
|
15 |
+
history_langchain_format.append(AIMessage(content=ai))
|
16 |
+
history_langchain_format.append(HumanMessage(content=message))
|
17 |
+
gpt_response = llm(history_langchain_format)
|
18 |
+
return gpt_response.content
|
19 |
+
|
20 |
+
gr.ChatInterface(predict).launch()
|