mirror of
https://github.com/run-llama/create-llama.git
synced 2026-07-01 21:04:08 -04:00
fix: unused imports and format (#705)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"create-llama": patch
|
||||
---
|
||||
|
||||
fix: unused imports and format
|
||||
@@ -5,6 +5,7 @@ from llama_index.core.base.base_query_engine import BaseQueryEngine
|
||||
from llama_index.core.indices.base import BaseIndex
|
||||
from llama_index.core.tools.query_engine import QueryEngineTool
|
||||
|
||||
|
||||
def create_query_engine(index: BaseIndex, **kwargs: Any) -> BaseQueryEngine:
|
||||
"""
|
||||
Create a query engine for the given index.
|
||||
|
||||
@@ -29,6 +29,7 @@ from src.settings import init_settings
|
||||
from pydantic import BaseModel, Field
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
def create_workflow() -> Workflow:
|
||||
load_dotenv()
|
||||
init_settings()
|
||||
|
||||
@@ -9,7 +9,11 @@ from llama_index.core.agent.workflow.workflow_events import AgentStream
|
||||
|
||||
|
||||
async def write_response_to_stream(
|
||||
res: Union[CompletionResponse, CompletionResponseAsyncGen, AsyncGenerator[ChatResponse, None]],
|
||||
res: Union[
|
||||
CompletionResponse,
|
||||
CompletionResponseAsyncGen,
|
||||
AsyncGenerator[ChatResponse, None],
|
||||
],
|
||||
ctx: Context,
|
||||
current_agent_name: str = "assistant",
|
||||
) -> str:
|
||||
@@ -35,7 +39,7 @@ async def write_response_to_stream(
|
||||
response=final_response,
|
||||
current_agent_name=current_agent_name,
|
||||
tool_calls=[],
|
||||
raw=getattr(chunk, 'raw', None) or "",
|
||||
raw=getattr(chunk, "raw", None) or "",
|
||||
)
|
||||
)
|
||||
final_response += chunk.delta or ""
|
||||
|
||||
+1
-1
@@ -585,4 +585,4 @@ def _get_text_node_content_for_citation(node: NodeWithScore) -> str:
|
||||
return content
|
||||
|
||||
|
||||
workflow = create_workflow()
|
||||
workflow = create_workflow()
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
import re
|
||||
import time
|
||||
from typing import Any, Literal, Optional, Union
|
||||
from typing import Any, Literal, Optional
|
||||
|
||||
from llama_index.core import Settings
|
||||
from llama_index.core.llms import LLM, ChatMessage
|
||||
@@ -29,11 +29,13 @@ from src.settings import init_settings
|
||||
from pydantic import BaseModel, Field
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
def create_workflow() -> Workflow:
|
||||
load_dotenv()
|
||||
init_settings()
|
||||
return DocumentArtifactWorkflow(timeout=120.0)
|
||||
|
||||
|
||||
class DocumentRequirement(BaseModel):
|
||||
type: Literal["markdown", "html"]
|
||||
title: str
|
||||
|
||||
+3
-4
@@ -8,7 +8,7 @@ from io import BytesIO
|
||||
from llama_index.core.tools.function_tool import FunctionTool
|
||||
|
||||
# use nextjs for file server
|
||||
WORKFLOW="chat"
|
||||
WORKFLOW = "chat"
|
||||
|
||||
# define nextjs file server url prefix
|
||||
FILE_SERVER_URL_PREFIX = f"/deployments/{WORKFLOW}/ui/api/files/output/tools"
|
||||
@@ -19,6 +19,7 @@ FILE_SERVER_URL_PREFIX = f"/deployments/{WORKFLOW}/ui/api/files/output/tools"
|
||||
LLAMA_DEPLOY_DIR = os.path.join(tempfile.gettempdir(), "llama_deploy", "deployments")
|
||||
OUTPUT_DIR = os.path.join(LLAMA_DEPLOY_DIR, WORKFLOW, "ui", "output", "tools")
|
||||
|
||||
|
||||
class DocumentType(Enum):
|
||||
PDF = "pdf"
|
||||
HTML = "html"
|
||||
@@ -206,9 +207,7 @@ class DocumentGenerator:
|
||||
|
||||
self._write_to_file(content, file_path)
|
||||
|
||||
return (
|
||||
f"{self.file_server_url_prefix}/{file_name}.{file_extension}"
|
||||
)
|
||||
return f"{self.file_server_url_prefix}/{file_name}.{file_extension}"
|
||||
|
||||
@staticmethod
|
||||
def _write_to_file(content: BytesIO, file_path: str) -> None:
|
||||
|
||||
+3
-1
@@ -25,8 +25,10 @@ class InputEvent(Event):
|
||||
class ResearchEvent(Event):
|
||||
input: list[ToolSelection]
|
||||
|
||||
|
||||
class AnalyzeEvent(Event):
|
||||
input: list[ToolSelection] | ChatMessage
|
||||
|
||||
|
||||
class ReportEvent(Event):
|
||||
input: list[ToolSelection]
|
||||
input: list[ToolSelection]
|
||||
|
||||
-1
@@ -3,7 +3,6 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
@@ -5,6 +5,7 @@ from llama_index.core.base.base_query_engine import BaseQueryEngine
|
||||
from llama_index.core.indices.base import BaseIndex
|
||||
from llama_index.core.tools.query_engine import QueryEngineTool
|
||||
|
||||
|
||||
def create_query_engine(index: BaseIndex, **kwargs: Any) -> BaseQueryEngine:
|
||||
"""
|
||||
Create a query engine for the given index.
|
||||
|
||||
+6
-2
@@ -9,7 +9,11 @@ from llama_index.core.agent.workflow.workflow_events import AgentStream
|
||||
|
||||
|
||||
async def write_response_to_stream(
|
||||
res: Union[CompletionResponse, CompletionResponseAsyncGen, AsyncGenerator[ChatResponse, None]],
|
||||
res: Union[
|
||||
CompletionResponse,
|
||||
CompletionResponseAsyncGen,
|
||||
AsyncGenerator[ChatResponse, None],
|
||||
],
|
||||
ctx: Context,
|
||||
current_agent_name: str = "assistant",
|
||||
) -> str:
|
||||
@@ -35,7 +39,7 @@ async def write_response_to_stream(
|
||||
response=final_response,
|
||||
current_agent_name=current_agent_name,
|
||||
tool_calls=[],
|
||||
raw=getattr(chunk, 'raw', None) or "",
|
||||
raw=getattr(chunk, "raw", None) or "",
|
||||
)
|
||||
)
|
||||
final_response += chunk.delta or ""
|
||||
|
||||
+2
-4
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
from typing import List, Optional
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
@@ -8,10 +7,9 @@ from llama_index.core import Settings
|
||||
from llama_index.core.base.llms.types import ChatMessage, MessageRole
|
||||
from llama_index.core.llms.function_calling import FunctionCallingLLM
|
||||
from llama_index.core.memory import ChatMemoryBuffer
|
||||
from llama_index.core.tools import FunctionTool, QueryEngineTool, ToolSelection
|
||||
from llama_index.core.tools import FunctionTool, QueryEngineTool
|
||||
from llama_index.core.workflow import (
|
||||
Context,
|
||||
Event,
|
||||
StartEvent,
|
||||
StopEvent,
|
||||
Workflow,
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import typing
|
||||
from io import BytesIO
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
||||
from typing import Dict, Optional, Tuple, Union
|
||||
|
||||
from llama_cloud import ManagedIngestionStatus, PipelineFileCreateCustomMetadataValue
|
||||
from pydantic import BaseModel
|
||||
|
||||
Reference in New Issue
Block a user