Skip to content

Commit

Permalink
Naming update
Browse files Browse the repository at this point in the history
  • Loading branch information
Крестников Константин Николаевич authored and Крестников Константин Николаевич committed Oct 30, 2023
1 parent 971a4bf commit 36bb33f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 26 deletions.
50 changes: 26 additions & 24 deletions examples/giga_chain/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from langchain.chat_models.gigachat import GigaChat
from langchain.prompts import load_prompt
from langchain.text_splitter import CharacterTextSplitter
from langchain.pydantic_v1 import BaseModel

from langserve import add_routes

Expand All @@ -19,32 +20,25 @@
logging.basicConfig(level=logging.INFO)


def build_chain():
giga = GigaChat(
profanity=False,
verbose=True,
verify_ssl_certs=False,
user=user,
password=password,
base_url="https://wmapi-dev.saluteai-pd.sberdevices.ru/v1",
model="GigaChat-70b-4k-base:latest",
timeout=30,)
giga = GigaChat(
profanity=False,
verbose=True,
timeout=30)

map_prompt = load_prompt("lc://prompts/summarize/map_reduce/map.yaml")
combine_prompt = load_prompt("lc://prompts/summarize/map_reduce/combine.yaml")
map_prompt = load_prompt("lc://prompts/summarize/map_reduce/map.yaml")
combine_prompt = load_prompt("lc://prompts/summarize/map_reduce/combine.yaml")

splitter = CharacterTextSplitter(chunk_size=12000, chunk_overlap=1000)
combine_chain = load_summarize_chain(
giga,
chain_type="map_reduce",
map_prompt=map_prompt,
combine_prompt=combine_prompt,
)
return AnalyzeDocumentChain(
combine_docs_chain=combine_chain, text_splitter=splitter
)
splitter = CharacterTextSplitter(chunk_size=12000, chunk_overlap=1000)
combine_chain = load_summarize_chain(
giga,
chain_type="map_reduce",
map_prompt=map_prompt,
combine_prompt=combine_prompt,
)

chain = build_chain()
chain = AnalyzeDocumentChain(
combine_docs_chain=combine_chain, text_splitter=splitter
)

app = FastAPI(
title="GigaChain Server",
Expand All @@ -62,7 +56,15 @@ def build_chain():
expose_headers=["*"],
)

add_routes(app, chain)
# The input type is automatically inferred from the runnable
# interface; however, if you want to override it, you can do so
# by passing in the input_type argument to add_routes.
class ChainInput(BaseModel):
"""The input to the chain."""
token: str
input_document: str

add_routes(app, chain, config_keys=["configurable"])

if __name__ == "__main__":
import uvicorn
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[tool.poetry]
name = "langserve"
name = "gigaserve"
version = "0.0.19"
description = ""
readme = "README.md"
authors = ["LangChain"]
authors = ["LangChain", "GigaChain"]
license = "LangServe"
repository = "https://github.com/langchain-ai/langserve"
exclude = ["langserve/playground"]
include = ["langserve/playground/dist/**/*"]
packages = [
{include = "langserve"}
]

[tool.poetry.dependencies]
python = "^3.8.1"
Expand Down

0 comments on commit 36bb33f

Please sign in to comment.