Rename embedchain to mem0 and open sourcing code for long term memory (#1474)

Co-authored-by: Deshraj Yadav <deshrajdry@gmail.com>
This commit is contained in:
Taranjeet Singh
2024-07-12 20:21:33 +05:30
committed by GitHub
co-authored by Deshraj Yadav
parent 83e8c97295
commit f842a92e25
665 changed files with 9427 additions and 6592 deletions
@@ -0,0 +1 @@
OPENAI_API_KEY=sk-xxx
@@ -0,0 +1 @@
.env
@@ -0,0 +1,53 @@
from fastapi import FastAPI, responses
from pydantic import BaseModel
from embedchain import App
app = FastAPI(title="Embedchain FastAPI App")
embedchain_app = App()
class SourceModel(BaseModel):
source: str
class QuestionModel(BaseModel):
question: str
@app.post("/add")
async def add_source(source_model: SourceModel):
"""
Adds a new source to the EmbedChain app.
Expects a JSON with a "source" key.
"""
source = source_model.source
embedchain_app.add(source)
return {"message": f"Source '{source}' added successfully."}
@app.post("/query")
async def handle_query(question_model: QuestionModel):
"""
Handles a query to the EmbedChain app.
Expects a JSON with a "question" key.
"""
question = question_model.question
answer = embedchain_app.query(question)
return {"answer": answer}
@app.post("/chat")
async def handle_chat(question_model: QuestionModel):
"""
Handles a chat request to the EmbedChain app.
Expects a JSON with a "question" key.
"""
question = question_model.question
response = embedchain_app.chat(question)
return {"response": response}
@app.get("/")
async def root():
return responses.RedirectResponse(url="/docs")
@@ -0,0 +1,16 @@
services:
- type: web
name: ec-render-app
runtime: python
repo: https://github.com/<your-username>/<repo-name>
scaling:
minInstances: 1
maxInstances: 3
targetMemoryPercent: 60 # optional if targetCPUPercent is set
targetCPUPercent: 60 # optional if targetMemory is set
buildCommand: pip install -r requirements.txt
startCommand: uvicorn app:app --host 0.0.0.0
envVars:
- key: OPENAI_API_KEY
value: sk-xxx
autoDeploy: false # optional
@@ -0,0 +1,4 @@
fastapi==0.104.0
uvicorn==0.23.2
embedchain
beautifulsoup4