Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ideas for search query #1

Open
titipata opened this issue Feb 9, 2024 · 0 comments
Open

Ideas for search query #1

titipata opened this issue Feb 9, 2024 · 0 comments

Comments

@titipata
Copy link
Contributor

titipata commented Feb 9, 2024

Some ideas for CSV query @boom4869.

OpenAI prompt

from openai import OpenAI

client = OpenAI(api_key = "sk-...")

def get_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",
    )

    return response.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
import json
query = "กำลังมองหาแพทย์ที่เชี่ยวชาญเกี่ยวกับมะเร็ง"
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant