Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/reformat #69

Merged
merged 20 commits into from
May 8, 2024
Prev Previous commit
Next Next commit
logic refine
  • Loading branch information
vyokky committed May 8, 2024
commit 9cf9bec03b54617348778bfc7025407d2fe4f4a8
9 changes: 5 additions & 4 deletions ufo/agent/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import json
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Dict, List, Type, Optional
from typing import Dict, List, Optional, Type

from ufo import utils
from ufo.module.state import Status
from ufo.llm import llm_call

from ufo.module.state import Status

# Lazy import the retriever factory to aviod long loading time.
retriever = utils.LazyImport("..rag.retriever")
Expand Down Expand Up @@ -251,7 +250,9 @@ def message_constructor(self) -> List[dict]:
pass

@classmethod
def get_response(cls, message: List[dict], namescope, use_backup_engine) -> str:
def get_response(
cls, message: List[dict], namescope: str, use_backup_engine: bool
) -> str:
"""
Get the response for the prompt.
:param prompt: The prompt.
Expand Down
11 changes: 10 additions & 1 deletion ufo/llm/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@


class OpenAIService(BaseService):
def __init__(self, config, agent_type: str):
"""
The OpenAI service class to interact with the OpenAI API.
"""

def __init__(self, config, agent_type: str) -> None:
"""
Create an OpenAI service instance.
:param config: The configuration for the OpenAI service.
:param agent_type: The type of the agent.
"""
self.config_llm = config[agent_type]
self.config = config
self.api_type = self.config_llm["API_TYPE"].lower()
Expand Down
38 changes: 19 additions & 19 deletions ufo/module/processors/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def __init__(
"""

super().__init__(
round_num,
log_path,
request,
request_logger,
logger,
round_step,
session_step,
prev_status,
app_window,
round_num=round_num,
log_path=log_path,
request=request,
request_logger=request_logger,
logger=logger,
round_step=round_step,
session_step=session_step,
prev_status=prev_status,
app_window=app_window,
)

self.host_agent = host_agent
Expand Down Expand Up @@ -419,15 +419,15 @@ def __init__(
"""

super().__init__(
round_num,
log_path,
request,
request_logger,
logger,
round_step,
session_step,
prev_status,
app_window,
round_num=round_num,
log_path=log_path,
request=request,
request_logger=request_logger,
logger=logger,
round_step=round_step,
session_step=session_step,
prev_status=prev_status,
app_window=app_window,
)

self.app_agent = app_agent
Expand Down Expand Up @@ -774,7 +774,7 @@ def update_status(self) -> None:
if self._status != Status.FINISH:
time.sleep(configs["SLEEP_TIME"])

def _safe_guard_judgement(self, action, control_text) -> bool:
def _safe_guard_judgement(self, action: str, control_text: str) -> bool:
"""
Safe guard for the session.
action: The action to be taken.
Expand Down