Skip to content

Commit

Permalink
Merge branch 'master' into fix_base_agent_mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
lightaime authored Jul 2, 2023
2 parents d6ac6f0 + aea5b86 commit 5371336
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions camel/prompts/ai_society.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AISocietyPromptTemplateDict(TextPromptDict):
Please reply with the specified task in {word_limit} words or less. Do not add anything else."""
)

ASSISTANT_PROMPT = TextPrompt(
ASSISTANT_PROMPT: TextPrompt = TextPrompt(
"""Never forget you are a {assistant_role} and I am a {user_role}. Never flip roles! Never instruct me!
We share a common interest in collaborating to successfully complete a task.
You must help me to complete the task.
Expand All @@ -75,7 +75,7 @@ class AISocietyPromptTemplateDict(TextPromptDict):
<YOUR_SOLUTION> should be very specific, include detailed explanations and provide preferable detailed implementations and examples and lists for task-solving.
Always end <YOUR_SOLUTION> with: Next request.""")

USER_PROMPT = TextPrompt(
USER_PROMPT: TextPrompt = TextPrompt(
"""Never forget you are a {user_role} and I am a {assistant_role}. Never flip roles! You will always instruct me.
We share a common interest in collaborating to successfully complete a task.
I must help you to complete the task.
Expand Down
14 changes: 7 additions & 7 deletions camel/prompts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@


def return_prompt_wrapper(
cls: T,
cls: Any,
func: Callable,
) -> Callable[..., Union[T, tuple]]:
) -> Callable[..., Union[Any, tuple]]:
r"""Wrapper that converts the return value of a function to an input
class instance if it's a string.
Args:
cls (type): The class to convert to.
cls (Any): The class to convert to.
func (Callable): The function to decorate.
Returns:
Callable[..., Union[T, tuple]]: Decorated function that
Callable[..., Union[Any, str]]: Decorated function that
returns the decorated class instance if the return value is a
string.
"""

def wrapper(*args: Any, **kwargs: Any) -> Union[T, tuple]:
def wrapper(*args: Any, **kwargs: Any) -> Union[Any, str]:
r"""Wrapper function that performs the conversion to :obj:`TextPrompt`
instance.
Expand All @@ -45,7 +45,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Union[T, tuple]:
**kwargs (Any): Arbitrary keyword arguments.
Returns:
Union[TextPrompt, tuple]: The converted return value.
Union[Any, str]: The converted return value.
"""
result = func(*args, **kwargs)
if isinstance(result, str) and not isinstance(result, cls):
Expand Down Expand Up @@ -185,7 +185,7 @@ def execute(
sys.stdout = output_str

global_vars = global_vars or globals()
local_vars = {}
local_vars: Dict[str, Any] = {}
exec(
self,
global_vars,
Expand Down
4 changes: 2 additions & 2 deletions camel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import time
import zipfile
from functools import wraps
from typing import Any, Callable, List, Optional, Set, TypeVar
from typing import Any, Callable, List, Optional, Set, TypeVar, cast

import requests
import tiktoken
Expand Down Expand Up @@ -167,7 +167,7 @@ def wrapper(self, *args, **kwargs):
else:
raise ValueError('OpenAI API key not found.')

return wrapper
return cast(F, wrapper)


def print_text_animated(text, delay: float = 0.02, end: str = ""):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tenacity = "^8"
tiktoken = "^0"
colorama = "^0"
types-colorama = "^0"
types-requests = "^2"
yapf = "^0"
isort = "^5"
flake8 = "^6"
Expand Down

0 comments on commit 5371336

Please sign in to comment.