Spaces:
Sleeping
Sleeping
Commit ·
6fea6fd
1
Parent(s): 0270f74
Api key access through .env
Browse files- src/generation/generate.py +5 -1
- src/retrieval/query.py +1 -1
src/generation/generate.py
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
import requests
|
| 2 |
from src.retrieval.query import retrieve
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def build_prompt(query, context):
|
| 5 |
return f"""You are a helpful assistant. Answer using ONLY the context below. Do NOT use outside knowledge.
|
|
@@ -79,7 +83,7 @@ def generate_answer(prompt, model="llama-3.1-8b-instant"):
|
|
| 79 |
response = requests.post(
|
| 80 |
"https://api.groq.com/openai/v1/chat/completions",
|
| 81 |
headers={
|
| 82 |
-
"Authorization": f"Bearer {
|
| 83 |
"Content-Type": "application/json"
|
| 84 |
},
|
| 85 |
json={
|
|
|
|
| 1 |
import requests
|
| 2 |
from src.retrieval.query import retrieve
|
| 3 |
+
import os
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
|
| 8 |
def build_prompt(query, context):
|
| 9 |
return f"""You are a helpful assistant. Answer using ONLY the context below. Do NOT use outside knowledge.
|
|
|
|
| 83 |
response = requests.post(
|
| 84 |
"https://api.groq.com/openai/v1/chat/completions",
|
| 85 |
headers={
|
| 86 |
+
"Authorization": f"Bearer {os.environ.get('GROQ_API_KEY')}",
|
| 87 |
"Content-Type": "application/json"
|
| 88 |
},
|
| 89 |
json={
|
src/retrieval/query.py
CHANGED
|
@@ -158,7 +158,7 @@ RERANK_THRESHOLD = 0.3
|
|
| 158 |
HYBRID_ALPHA = 0.7
|
| 159 |
|
| 160 |
def retrieve(query, top_k=7):
|
| 161 |
-
print(f"\
|
| 162 |
timings = {}
|
| 163 |
|
| 164 |
# --- EMBED ---
|
|
|
|
| 158 |
HYBRID_ALPHA = 0.7
|
| 159 |
|
| 160 |
def retrieve(query, top_k=7):
|
| 161 |
+
print(f"\nQuery: {query}")
|
| 162 |
timings = {}
|
| 163 |
|
| 164 |
# --- EMBED ---
|