mirror of
https://github.com/SirBlobby/Hoya26.git
synced 2026-02-04 03:34:34 -05:00
Database Viewer Update
This commit is contained in:
@@ -23,7 +23,33 @@ Based on the context provided, give a final verdict:
|
||||
|
||||
def ask(prompt):
|
||||
client = genai.Client(api_key=os.environ.get("GOOGLE_API_KEY"))
|
||||
return client.models.generate_content(model="gemini-2.0-flash", contents=prompt).text
|
||||
return client.models.generate_content(model="gemini-3-flash-preview", contents=prompt).text
|
||||
|
||||
def ask_gemini_with_rag(prompt, category=None):
|
||||
"""Ask Gemini with RAG context from the vector database."""
|
||||
# Get embedding for the prompt
|
||||
query_embedding = get_embedding(prompt)
|
||||
|
||||
# Search for relevant documents
|
||||
results = search_documents(query_embedding, num_results=5)
|
||||
|
||||
# Build context from results
|
||||
context = ""
|
||||
for res in results:
|
||||
context += f"--- Document ---\n{res['text']}\n\n"
|
||||
|
||||
# Create full prompt with context
|
||||
full_prompt = f"""You are a helpful sustainability assistant. Use the following context to answer the user's question.
|
||||
If the context doesn't contain relevant information, you can use your general knowledge but mention that.
|
||||
|
||||
CONTEXT:
|
||||
{context}
|
||||
|
||||
USER QUESTION: {prompt}
|
||||
|
||||
Please provide a helpful and concise response."""
|
||||
|
||||
return ask(full_prompt)
|
||||
|
||||
def analyze(query, query_embedding, num_results=5, num_alternatives=3):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user