Spaces:
Sleeping
Sleeping
Commit ·
5ea7454
1
Parent(s): bba3ad7
updated agent
Browse files
agent.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
# agent.py — Gemini-based Coding Agent with PDF/.py RAG + Memory (.env support)
|
| 2 |
import os
|
| 3 |
import fitz
|
| 4 |
import faiss
|
|
@@ -10,10 +9,10 @@ from sentence_transformers import SentenceTransformer
|
|
| 10 |
|
| 11 |
class CodingAgent:
|
| 12 |
def __init__(self):
|
| 13 |
-
|
| 14 |
load_dotenv()
|
| 15 |
|
| 16 |
-
|
| 17 |
self.api_key = os.getenv("GEMINI_API_KEY")
|
| 18 |
if not self.api_key:
|
| 19 |
raise ValueError("GEMINI_API_KEY not found in environment or .env file.")
|
|
@@ -21,12 +20,12 @@ class CodingAgent:
|
|
| 21 |
genai.configure(api_key=self.api_key)
|
| 22 |
self.model = genai.GenerativeModel("gemini-1.5-flash")
|
| 23 |
|
| 24 |
-
|
| 25 |
self.embedder = SentenceTransformer("all-MiniLM-L6-v2")
|
| 26 |
self.index = faiss.IndexFlatL2(384)
|
| 27 |
self.docs = []
|
| 28 |
|
| 29 |
-
|
| 30 |
self.conn = sqlite3.connect("memory.db", check_same_thread=False)
|
| 31 |
self.conn.execute(
|
| 32 |
"""CREATE TABLE IF NOT EXISTS memory (id INTEGER PRIMARY KEY, query TEXT, response TEXT)"""
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import fitz
|
| 3 |
import faiss
|
|
|
|
| 9 |
|
| 10 |
class CodingAgent:
|
| 11 |
def __init__(self):
|
| 12 |
+
|
| 13 |
load_dotenv()
|
| 14 |
|
| 15 |
+
|
| 16 |
self.api_key = os.getenv("GEMINI_API_KEY")
|
| 17 |
if not self.api_key:
|
| 18 |
raise ValueError("GEMINI_API_KEY not found in environment or .env file.")
|
|
|
|
| 20 |
genai.configure(api_key=self.api_key)
|
| 21 |
self.model = genai.GenerativeModel("gemini-1.5-flash")
|
| 22 |
|
| 23 |
+
|
| 24 |
self.embedder = SentenceTransformer("all-MiniLM-L6-v2")
|
| 25 |
self.index = faiss.IndexFlatL2(384)
|
| 26 |
self.docs = []
|
| 27 |
|
| 28 |
+
|
| 29 |
self.conn = sqlite3.connect("memory.db", check_same_thread=False)
|
| 30 |
self.conn.execute(
|
| 31 |
"""CREATE TABLE IF NOT EXISTS memory (id INTEGER PRIMARY KEY, query TEXT, response TEXT)"""
|