Download app.py from EJCS/roleQaGpt: direct link, hf CLI and curl.
- Browser
- Download file 654 Bytes
-
https://huggingface.co/spaces/EJCS/roleQaGpt/resolve/main/app.py
- Command line
-
hf download hf://spaces/EJCS/roleQaGpt/app.py
-
curl -L -o app.py https://huggingface.co/spaces/EJCS/roleQaGpt/resolve/main/app.py
654 Bytes
| import gradio as gr | |
| import openai, subprocess, os | |
| from agents import agente | |
| from dotenv import load_dotenv | |
| openai.api_key = os.getenv('SECRET_API_KEY') | |
| setupInicial, titulo = agente("qa") | |
| messages = [{"role": "system", "content": setupInicial}] | |
| def chatea (pregunta, history): | |
| global messages | |
| messages.append({"role": "user", "content": pregunta}) | |
| response = openai.chat.completions.create(model="gpt-4",messages=messages) | |
| system_message = response.choices[0].message.content | |
| return system_message | |
| ui = gr.ChatInterface(fn=chatea, title=titulo, retry_btn=None, undo_btn=None, clear_btn=None, submit_btn="Enviar") | |
| ui.launch(share=True) |