Upload 3 files
Browse files- .env +4 -0
- requirements.txt +29 -0
- serve.py +42 -0
.env
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
COHERE_API_KEY="kF8b3kIkSyA5CLYjnULZPJaGSSZK8Z3JZvwUOTZO"
|
| 2 |
+
LANGCHAIN_API_KEY="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"
|
| 3 |
+
LANGCHAIN_PROJECT="APP"
|
| 4 |
+
GROQ_API_KEY="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"
|
requirements.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
langchain
|
| 2 |
+
python-dotenv
|
| 3 |
+
ipykernel
|
| 4 |
+
langchain_community
|
| 5 |
+
pypdf
|
| 6 |
+
bs4
|
| 7 |
+
arxiv
|
| 8 |
+
pymupdf
|
| 9 |
+
fitz
|
| 10 |
+
wikipedia
|
| 11 |
+
langchain-text-splitters
|
| 12 |
+
streamlit
|
| 13 |
+
python-docx
|
| 14 |
+
pdfplumber
|
| 15 |
+
docx2txt
|
| 16 |
+
openai
|
| 17 |
+
langchain
|
| 18 |
+
python-dotenv
|
| 19 |
+
xlsxwriter
|
| 20 |
+
python-docx
|
| 21 |
+
lxml==5.2.1
|
| 22 |
+
docx
|
| 23 |
+
langchain_core
|
| 24 |
+
langchain_groq
|
| 25 |
+
langchain_openai
|
| 26 |
+
fastapi
|
| 27 |
+
langserve
|
| 28 |
+
sse_starlette
|
| 29 |
+
uvicorn
|
serve.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from langchain_core.prompts import ChatPromptTemplate
|
| 3 |
+
from langchain_core.output_parsers import StrOutputParser
|
| 4 |
+
from langchain_groq import ChatGroq
|
| 5 |
+
import os
|
| 6 |
+
from langserve import add_routes
|
| 7 |
+
from dotenv import load_dotenv
|
| 8 |
+
load_dotenv()
|
| 9 |
+
|
| 10 |
+
import openai
|
| 11 |
+
|
| 12 |
+
##groq_api_key = os.getenv("GROQ_API_KEY")
|
| 13 |
+
groq_api_key = "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"
|
| 14 |
+
model=ChatGroq(model="Gemma2-9b-It", groq_api_key=groq_api_key)
|
| 15 |
+
|
| 16 |
+
# Create prompt templates
|
| 17 |
+
system_template = "Translate the following into {language}:"
|
| 18 |
+
prompt_template = ChatPromptTemplate.from_messages([
|
| 19 |
+
("system",system_template),
|
| 20 |
+
("user","{text}")
|
| 21 |
+
])
|
| 22 |
+
|
| 23 |
+
parser=StrOutputParser()
|
| 24 |
+
|
| 25 |
+
##create chain
|
| 26 |
+
chain=prompt_template|model|parser
|
| 27 |
+
|
| 28 |
+
##app definition
|
| 29 |
+
app=FastAPI(title="Langchain server",
|
| 30 |
+
version="1.0",
|
| 31 |
+
description="A simple API server using langchain runnable interfaces")
|
| 32 |
+
|
| 33 |
+
#add chain routes
|
| 34 |
+
add_routes(
|
| 35 |
+
app,
|
| 36 |
+
chain,
|
| 37 |
+
path="/chain"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
if __name__=="__main__":
|
| 41 |
+
import uvicorn
|
| 42 |
+
uvicorn.run(app,host="127.0.0.1",port=8000)
|