You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromopenaiimportOpenAIclient=OpenAI(api_key="sk-...")
defget_openai_response(prompt, max_tokens=1000):
""" Sends a prompt to the OpenAI API and returns the generated output. Parameters: - prompt (str): The input prompt for the model. - model (str): The model to use, e.g., "text-davinci-002". - max_tokens (int): The maximum number of tokens in the generated output. Returns: - str: The generated output from the OpenAI model. """response=client.chat.completions.create(
messages=[
{
"role": "user",
"content": prompt,
}
],
model="gpt-3.5-turbo",
)
returnresponse.choices[0].message.content
Adding keywords to the search list
expertise="อายุรศาสตร์ โรคติดเชื้อ"prompt=f"""Find 10 most relevant Thai keywords related to {expertise} and return as a list. This will be mainly used for indexing the keyword for search.""".strip()
keywords=get_openai_response(prompt)
Converting search query to a list of keywords
importjsonquery="กำลังมองหาแพทย์ที่เชี่ยวชาญเกี่ยวกับมะเร็ง"prompt=f"""- Try to extract keywords from the following query: {query}.\- Parse the output to a list in JSON format""".strip()
keywords=get_openai_response(prompt)
json.loads(keywords)
Converting datetime in string to date range
check_schedule=df.table_check.iloc[100]
print(check_schedule)
prompt=f"Convert the given schedules in Thai to a list of datetime range i.e. [(Friday 8:00, Friday 11:30), (Saturday 8:30, Saturday 11:30)] in Python datetime. Do not write the code, just return an output as a list. Schedule: {check_schedule}"available_datetime=get_openai_response(prompt)
print(available_datetime)
query=f"สอบถามแพทย์ที่ว่างวันพุธเช้า"prompt=f"If user asks about available time for the visit, convert the query into datetime range i.e. [(Friday 8:00, Friday 12:00), ...]. User query: ```{query}```"get_openai_response(prompt)
The text was updated successfully, but these errors were encountered:
Some ideas for CSV query @boom4869.
OpenAI prompt
The text was updated successfully, but these errors were encountered: