Spaces:
Sleeping
Sleeping
File size: 1,312 Bytes
8366c08 0f08318 8366c08 a92579f 5b84489 8366c08 5b84489 8366c08 5b84489 8366c08 5b84489 8366c08 5b84489 8366c08 5b84489 8366c08 5b84489 8366c08 5b84489 |
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 41 42 43 44 45 |
import streamlit as st
import streamlit as st
from openai import OpenAI
import json
import os
openai_api_key = os.getenv('OPENAI_API_KEY')
client = OpenAI(api_key=openai_api_key)
job_id = os.getenv('job_id')
response = client.fine_tuning.jobs.retrieve(job_id)
st.title("AI Assistant - Fine-Tuned Model")
user_input = st.text_input("Enter your question:")
if st.button("Ask"):
if user_input:
try:
completion = client.chat.completions.create(
model="ft:gpt-3.5-turbo-0125:personal::AVdWfIMJ",
messages=[
{"role": "system", "content": "You are an assistant trained to translate natural language requests into OpenSearch queries. Use a step-by-step approach to break down the user's request, identify components like filters, aggregations, and sort criteria, and generate a valid OpenSearch JSON query."},
{"role": "user", "content": user_input}
]
)
st.write("Assistant's response:")
st.write(completion.choices[0].message.content)
except Exception as e:
st.write("Error:", e)
else:
st.write("Please enter a question.")
|