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

360 #79

Open
1atAlcone opened this issue Nov 21, 2024 · 0 comments
Open

360 #79

1atAlcone opened this issue Nov 21, 2024 · 0 comments

Comments

@1atAlcone
Copy link

def generate_llm_response(messages, processed_results) -> str:
SYSTEM_PROMPT = """You're an AI assistant that writes technical documentation. You can search a vector store for
information relevant to the user's query. Use the provided vector store results to inform your response, but don't
mention the vector store directly."""

vs_results = "\n=========\n".join(
    [f"{result.get('chunk_text', 'No text available')}" for result in processed_results]
)
messages = [
    {"role": "system", "content": SYSTEM_PROMPT},
    *messages,
    {
        "role": "system",
        "content": f"User query: {messages[-1]['content']}\n\nRelevant information:\n{vs_results}",
    },
]
return inference.completions(model="qwen2p5-72b-instruct", messages=messages, max_tokens=16000)

Get an LLM response using the vector store

search_query = "example search query"
client_config = ClientConfig(base_url=CONFIG.nearai_hub.base_url, auth=CONFIG.auth)
inference = InferenceRouter(client_config)
vector_results = inference.query_vector_store(vs.id, search_query)
processed_results = process_vector_results([vector_results])
llm_response = generate_llm_response(messages, processed_results)
print(llm_response["choices"][0]["message"]["content"])

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