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:
1
embedchain/examples/nextjs/ec_app/.dockerignore
Normal file
1
embedchain/examples/nextjs/ec_app/.dockerignore
Normal file
@@ -0,0 +1 @@
|
||||
db/
|
||||
1
embedchain/examples/nextjs/ec_app/.env.example
Normal file
1
embedchain/examples/nextjs/ec_app/.env.example
Normal file
@@ -0,0 +1 @@
|
||||
OPENAI_API_KEY=sk-xxx
|
||||
13
embedchain/examples/nextjs/ec_app/Dockerfile
Normal file
13
embedchain/examples/nextjs/ec_app/Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt /app/
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY . /app
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]
|
||||
56
embedchain/examples/nextjs/ec_app/app.py
Normal file
56
embedchain/examples/nextjs/ec_app/app.py
Normal file
@@ -0,0 +1,56 @@
|
||||
from dotenv import load_dotenv
|
||||
from fastapi import FastAPI, responses
|
||||
from pydantic import BaseModel
|
||||
|
||||
from embedchain import App
|
||||
|
||||
load_dotenv(".env")
|
||||
|
||||
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")
|
||||
3
embedchain/examples/nextjs/ec_app/embedchain.json
Normal file
3
embedchain/examples/nextjs/ec_app/embedchain.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"provider": "fly.io"
|
||||
}
|
||||
22
embedchain/examples/nextjs/ec_app/fly.toml
Normal file
22
embedchain/examples/nextjs/ec_app/fly.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
# fly.toml app configuration file generated for ec-app-crimson-dew-123 on 2024-01-04T06:48:40+05:30
|
||||
#
|
||||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
||||
#
|
||||
|
||||
app = "ec-app-crimson-dew-123"
|
||||
primary_region = "sjc"
|
||||
|
||||
[build]
|
||||
|
||||
[http_service]
|
||||
internal_port = 8080
|
||||
force_https = true
|
||||
auto_stop_machines = false
|
||||
auto_start_machines = true
|
||||
min_machines_running = 0
|
||||
processes = ["app"]
|
||||
|
||||
[[vm]]
|
||||
cpu_kind = "shared"
|
||||
cpus = 1
|
||||
memory_mb = 1024
|
||||
4
embedchain/examples/nextjs/ec_app/requirements.txt
Normal file
4
embedchain/examples/nextjs/ec_app/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
fastapi==0.104.0
|
||||
uvicorn==0.23.2
|
||||
embedchain
|
||||
beautifulsoup4
|
||||
Reference in New Issue
Block a user