Spaces:
Sleeping
Sleeping
File size: 955 Bytes
46fb1fc | 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 46 47 48 | from app.core.llm import get_llm
from app.memory.qdrant_memory import search_memory
async def generate_response(
user_id,
user_query
):
memories = search_memory(
user_id,
user_query
)
memory_context = "\n".join(memories)
SYSTEM_PROMPT = f"""
You are NeuroFlora,
an intelligent plant disease assistant.
Previous user memories:
{memory_context}
Help users with:
- plant diseases
- crop health
- farming guidance
- pesticide awareness
- plant care
"""
client = get_llm()
response = await client.chat.completions.create(
model="meta-llama/Llama-3.1-70B-Instruct:scaleway",
messages=[
{
"role": "system",
"content": SYSTEM_PROMPT
},
{
"role": "user",
"content": user_query
}
],
stream=True
)
return response |