Spaces:
Runtime error
Runtime error
Download app.py from Curranj/Words_To_SQL: direct link, hf CLI and curl.
- Browser
- Download file 771 Bytes
-
https://huggingface.co/spaces/Curranj/Words_To_SQL/resolve/main/app.py
- Command line
-
hf download hf://spaces/Curranj/Words_To_SQL/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Curranj/Words_To_SQL/resolve/main/app.py
771 Bytes
| import os | |
| from openai import OpenAI | |
| import gradio as gr | |
| client = OpenAI(api_key=os.environ["Secret"]) | |
| def gpt3(texts): | |
| response = client.chat.completions.create( | |
| model="gpt-4", | |
| messages=[{"role": "user", "content": texts}], | |
| temperature=0, | |
| max_tokens=750, | |
| top_p=1, | |
| frequency_penalty=0.0, | |
| presence_penalty=0.0, | |
| stop=[";", "*/", "</code>"] | |
| ) | |
| return response.choices[0].message.content | |
| def greet(prompt): | |
| txt = f'''/*Prompt: {prompt}*/ \nSQL code:''' | |
| sql = gpt3(txt) | |
| return sql | |
| e = gr.Interface( | |
| fn=greet, | |
| inputs=["text"], | |
| outputs="text", | |
| title="Natural Language to SQL Converter", | |
| description="Convert your natural language queries into SQL code." | |
| ) | |
| e.launch() |