Spaces:
Running
Running
File size: 1,087 Bytes
40b11ef 9b109b9 40b11ef 9b109b9 40b11ef 6dc27a3 714e389 6dc27a3 714e389 3093da2 4c09a77 40b11ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import gradio as gr
from langchain.agents.openai_assistant import OpenAIAssistantRunnable
from openai import OpenAI
import os
#sk
apikey = os.getenv('openAI') #key from client
agentkey = os.getenv('asstID')
os.environ["OPENAI_API_KEY"] = apikey
interpreter_assistant = OpenAIAssistantRunnable(assistant_id= agentkey) #, client = key
# output = interpreter_assistant.invoke({"content": "Hello?"})
# output[0].content[0].text.value
def chat_response(message, history):
output = interpreter_assistant.invoke({"content": message})
response = output[0].content[0].text.value
return response
css = """
label[data-testid="block-label"] {
display: none !important;
}
footer {
display: none !important;
}
"""
js_func = """
function refresh() {
const url = new URL(window.location);
if (url.searchParams.get('__theme') !== 'dark') {
url.searchParams.set('__theme', 'dark');
window.location.href = url.href;
}
}
"""
with gr.Blocks(css=css, js = js_func, theme="monochrome") as demo:
chatbot = gr.ChatInterface(chat_response)
demo.launch(share=True) |