QueryEnhancer.generate_litellm_queries:v0
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
import weave
import json
import litellm
from typing import List
@weave.op()
async def generate_litellm_queries(self, query: str, model: str = "gpt-4o-mini") -> List[str]:
"""
Generate search queries using LiteLLM.
Args:
query (str): The input query for which to generate search queries.
model (str, optional): The model to use. Defaults to "gpt-4o-mini".
Returns:
List[str]: A list of generated search queries.
"""
# load system prompt
messages = json.load(open("prompts/search_query.json", "r"))
# add user prompt (question)
messages.append({"role": "user", "content": f"## Question\n{query}"})
response = await litellm.acompletion(
model=model,
messages=messages,
temperature=0.5,
max_tokens=500,