Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from langchain.agents.openai_assistant import OpenAIAssistantRunnable
|
| 3 |
+
from openai import OpenAI
|
| 4 |
+
import os
|
| 5 |
+
#sk
|
| 6 |
+
apikey = os.getenv('openAI') #key from client
|
| 7 |
+
agentkey = os.getenv('asst')
|
| 8 |
+
os.environ["OPENAI_API_KEY"] =
|
| 9 |
+
|
| 10 |
+
interpreter_assistant = OpenAIAssistantRunnable(assistant_id=) #, client = key
|
| 11 |
+
# output = interpreter_assistant.invoke({"content": "Hello?"})
|
| 12 |
+
# output[0].content[0].text.value
|
| 13 |
+
|
| 14 |
+
def chat_response(message, history):
|
| 15 |
+
output = interpreter_assistant.invoke({"content": message})
|
| 16 |
+
response = output[0].content[0].text.value
|
| 17 |
+
return response
|
| 18 |
+
|
| 19 |
+
with gr.Blocks() as demo:
|
| 20 |
+
chatbot = gr.ChatInterface(chat_response)
|
| 21 |
+
|
| 22 |
+
demo.launch(share=True)
|