mirror of
https://github.com/lfnovo/open-notebook.git
synced 2026-04-29 12:00:00 +00:00
Version 1 (#160)
New front-end Launch Chat API Manage Sources Enable re-embedding of all contents Sources can be added without a notebook now Improved settings Enable model selector on all chats Background processing for better experience Dark mode Improved Notes Improved Docs: - Remove all Streamlit references from documentation - Update deployment guides with React frontend setup - Fix Docker environment variables format (SURREAL_URL, SURREAL_PASSWORD) - Update docker image tag from :latest to :v1-latest - Change navigation references (Settings → Models to just Models) - Update development setup to include frontend npm commands - Add MIGRATION.md guide for users upgrading from Streamlit - Update quick-start guide with correct environment variables - Add port 5055 documentation for API access - Update project structure to reflect frontend/ directory - Remove outdated source-chat documentation files
This commit is contained in:
parent
124d7d110c
commit
b7e656a319
319 changed files with 46747 additions and 7408 deletions
|
|
@ -17,17 +17,14 @@ from open_notebook.utils import clean_thinking_content
|
|||
class SubGraphState(TypedDict):
|
||||
question: str
|
||||
term: str
|
||||
# type: Literal["text", "vector"]
|
||||
instructions: str
|
||||
results: dict
|
||||
answer: str
|
||||
ids: list # Added for provide_answer function
|
||||
|
||||
|
||||
class Search(BaseModel):
|
||||
term: str
|
||||
# type: Literal["text", "vector"] = Field(
|
||||
# description="The type of search. Use 'text' for keyword search and 'vector' for semantic search. If you are using text, search always for a single word"
|
||||
# )
|
||||
instructions: str = Field(
|
||||
description="Tell the answeting LLM what information you need extracted from this search"
|
||||
)
|
||||
|
|
@ -50,8 +47,8 @@ class ThreadState(TypedDict):
|
|||
|
||||
async def call_model_with_messages(state: ThreadState, config: RunnableConfig) -> dict:
|
||||
parser = PydanticOutputParser(pydantic_object=Strategy)
|
||||
system_prompt = Prompter(prompt_template="ask/entry", parser=parser).render(
|
||||
data=state
|
||||
system_prompt = Prompter(prompt_template="ask/entry", parser=parser).render( # type: ignore[arg-type]
|
||||
data=state # type: ignore[arg-type]
|
||||
)
|
||||
model = await provision_langchain_model(
|
||||
system_prompt,
|
||||
|
|
@ -65,7 +62,8 @@ async def call_model_with_messages(state: ThreadState, config: RunnableConfig) -
|
|||
ai_message = await model.ainvoke(system_prompt)
|
||||
|
||||
# Clean the thinking content from the response
|
||||
cleaned_content = clean_thinking_content(ai_message.content)
|
||||
message_content = ai_message.content if isinstance(ai_message.content, str) else str(ai_message.content)
|
||||
cleaned_content = clean_thinking_content(message_content)
|
||||
|
||||
# Parse the cleaned JSON content
|
||||
strategy = parser.parse(cleaned_content)
|
||||
|
|
@ -99,7 +97,7 @@ async def provide_answer(state: SubGraphState, config: RunnableConfig) -> dict:
|
|||
payload["results"] = results
|
||||
ids = [r["id"] for r in results]
|
||||
payload["ids"] = ids
|
||||
system_prompt = Prompter(prompt_template="ask/query_process").render(data=payload)
|
||||
system_prompt = Prompter(prompt_template="ask/query_process").render(data=payload) # type: ignore[arg-type]
|
||||
model = await provision_langchain_model(
|
||||
system_prompt,
|
||||
config.get("configurable", {}).get("answer_model"),
|
||||
|
|
@ -107,11 +105,12 @@ async def provide_answer(state: SubGraphState, config: RunnableConfig) -> dict:
|
|||
max_tokens=2000,
|
||||
)
|
||||
ai_message = await model.ainvoke(system_prompt)
|
||||
return {"answers": [clean_thinking_content(ai_message.content)]}
|
||||
ai_content = ai_message.content if isinstance(ai_message.content, str) else str(ai_message.content)
|
||||
return {"answers": [clean_thinking_content(ai_content)]}
|
||||
|
||||
|
||||
async def write_final_answer(state: ThreadState, config: RunnableConfig) -> dict:
|
||||
system_prompt = Prompter(prompt_template="ask/final_answer").render(data=state)
|
||||
system_prompt = Prompter(prompt_template="ask/final_answer").render(data=state) # type: ignore[arg-type]
|
||||
model = await provision_langchain_model(
|
||||
system_prompt,
|
||||
config.get("configurable", {}).get("final_answer_model"),
|
||||
|
|
@ -119,7 +118,8 @@ async def write_final_answer(state: ThreadState, config: RunnableConfig) -> dict
|
|||
max_tokens=2000,
|
||||
)
|
||||
ai_message = await model.ainvoke(system_prompt)
|
||||
return {"final_answer": clean_thinking_content(ai_message.content)}
|
||||
final_content = ai_message.content if isinstance(ai_message.content, str) else str(ai_message.content)
|
||||
return {"final_answer": clean_thinking_content(final_content)}
|
||||
|
||||
|
||||
agent_state = StateGraph(ThreadState)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue