Spaces:
Sleeping
Sleeping
Initial Commit
Browse files- gpt4o_infer.py +4 -4
- requirements.txt +1 -1
gpt4o_infer.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
-
import openai
|
| 2 |
import os
|
|
|
|
| 3 |
|
| 4 |
-
openai.api_key
|
| 5 |
|
| 6 |
def call_gpt4o(prompt):
|
| 7 |
-
response =
|
| 8 |
model="gpt-4o",
|
| 9 |
messages=[
|
| 10 |
{"role": "system", "content": "You are a helpful assistant that converts natural language into SQL queries using the provided schema."},
|
|
@@ -13,4 +13,4 @@ def call_gpt4o(prompt):
|
|
| 13 |
temperature=0.2,
|
| 14 |
max_tokens=512
|
| 15 |
)
|
| 16 |
-
return response
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import openai
|
| 3 |
|
| 4 |
+
client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 5 |
|
| 6 |
def call_gpt4o(prompt):
|
| 7 |
+
response = client.chat.completions.create(
|
| 8 |
model="gpt-4o",
|
| 9 |
messages=[
|
| 10 |
{"role": "system", "content": "You are a helpful assistant that converts natural language into SQL queries using the provided schema."},
|
|
|
|
| 13 |
temperature=0.2,
|
| 14 |
max_tokens=512
|
| 15 |
)
|
| 16 |
+
return response.choices[0].message.content
|
requirements.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
gradio
|
| 2 |
-
openai
|
|
|
|
| 1 |
gradio
|
| 2 |
+
openai>=1.0.0
|