Database Viewer Update

This commit is contained in:
2026-01-25 00:16:48 +00:00
parent d37d925150
commit bae861c71f
15 changed files with 1726 additions and 846 deletions

View File

@@ -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: