Spaces:
Sleeping
Sleeping
Download app.py from ubs-ai/sql-server-expert: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/ubs-ai/sql-server-expert/resolve/main/app.py
- Command line
-
hf download hf://spaces/ubs-ai/sql-server-expert/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ubs-ai/sql-server-expert/resolve/main/app.py
1.25 kB
| import gradio as gr | |
| import tqdm | |
| from openai import OpenAI | |
| import os | |
| import dotenv | |
| dotenv.load_dotenv() | |
| gemini_client = OpenAI( | |
| api_key=os.getenv("GEMINI_API_KEY"), | |
| base_url=os.getenv("GEMINI_OPENAI_BASE_URL") | |
| ) | |
| def chat(message, history): | |
| promptmessage = [ | |
| { | |
| "role": "system", | |
| "content": "You are a SQL Server Expert. Answer any questions related to SQL Server. Please be explain answer clearly in brief and provide answers only if asked for it. Don;t give answer of anything else apart from SQL Server Questions. If User ask anything else please politely refuse to answer and remind them that you are a SQL Server Expert." | |
| }, | |
| { | |
| "role": "user", | |
| "content": "Question: " + message + "\n History: " + str(history) | |
| } | |
| ] | |
| response = gemini_client.chat.completions.create(model=os.getenv("GEMINI_MODEL_NAME"), messages=promptmessage) | |
| return response.choices[0].message.content | |
| demo = gr.ChatInterface(fn=chat, title="Pankaj's SQL Server Chatbot", description="Basic Chatbot that answers SQL Server related questions. You can ask for examples of your queries as well.") | |
| if __name__ == "__main__": | |
| demo.launch() |