Skip to content

Commit a0a945b

Browse files
python 3.10 ++
1 parent 7ff924a commit a0a945b

File tree

7 files changed

+827
-78
lines changed

7 files changed

+827
-78
lines changed

docs/examples/agents/react.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import inspect
33
import json
44
from collections.abc import Callable
5-
from typing import Literal
5+
from typing import Literal, Unpack
66

77
import pydantic
88
from jinja2 import Template
@@ -83,7 +83,7 @@ def call_tool(self, tool: ReactTool, kwargs_json: str):
8383
def tool_name_schema(self):
8484
names = self.tool_names()
8585
fields = dict()
86-
fields["tool"] = Literal[*names]
86+
fields["tool"] = Literal[Unpack[names]]
8787
return pydantic.create_model("ToolSelectionSchema", **fields)
8888

8989
def get_tool_from_schema(self, content: str):

docs/examples/agents/react_instruct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import inspect
33
import json
44
from collections.abc import Callable
5-
from typing import Literal
5+
from typing import Literal, Unpack
66

77
import pydantic
88
from jinja2 import Template
@@ -81,7 +81,7 @@ def call_tool(self, tool: ReactTool, kwargs_json: str):
8181
def tool_name_schema(self):
8282
names = self.tool_names()
8383
fields = dict()
84-
fields["tool"] = Literal[*names]
84+
fields["tool"] = Literal[Unpack[names]]
8585
return pydantic.create_model("ToolSelectionSchema", **fields)
8686

8787
def get_tool_from_schema(self, content: str):

docs/examples/mini_researcher/researcher.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,13 @@ def research_subtopic(main_topic: str, subtopic: str, context: list[RAGDocument]
232232
summaries = step_summarize_docs(
233233
m, docs=[c.content for c in context], user_args=user_args
234234
)
235-
print(f"Summaries: \n{'\n\n'.join([w(s) for s in summaries])}")
235+
summaries_str = "\n\n".join([w(s) for s in summaries])
236+
print(f"Summaries: \n{summaries_str}")
236237

237238
# Step 2: Generate Outline
238239
outline = step_generate_outline(m, user_args=user_args, context=context)
239-
print(f"Outline:\n{'\n'.join(outline)}")
240+
outline_str = "\n".join(outline)
241+
print(f"Outline:\n{outline_str}")
240242

241243
# Step 3: Merge all for the final report
242244
full_report = step_write_full_report(

docs/examples/rag/simple_rag_with_filter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def is_answer_relevant_to_question(answer: str, question: str) -> bool:
6464
# Query the index
6565
print("Query Embedding model...")
6666
results = query_index(embedding_model, index, query, docs)
67-
print(f"results:\n {'\n'.join([f'=> {r}' for r in results])}\n ====")
67+
results_str = "\n".join([f"=> {r}" for r in results])
68+
print(f"results:\n {results_str}\n ====")
6869
del embedding_model # help GC
6970

7071
# Create Mellea session

mellea/backends/openai.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from transformers.tokenization_utils import PreTrainedTokenizer
1919

2020
import mellea.backends.model_ids as model_ids
21+
from cli.serve.models import ChatCompletionMessage
2122
from mellea.backends import BaseModelSubclass
2223
from mellea.backends.aloras import Alora, AloraBackendMixin
2324
from mellea.backends.formatter import Formatter, FormatterBackend, TemplateFormatter
@@ -557,8 +558,8 @@ def _extract_model_tool_requests(
557558
calls = chat_response.choices[0].message.tool_calls
558559
if calls:
559560
for tool_call in calls:
560-
tool_name = tool_call.function.name
561-
tool_args = tool_call.function.arguments
561+
tool_name = tool_call.function.name # type: ignore
562+
tool_args = tool_call.function.arguments # type: ignore
562563

563564
func = tools.get(tool_name)
564565
if func is None:

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "pdm.backend"
44

55
[project]
66
name = "mellea"
7-
version = "0.0.1"
7+
version = "0.0.2"
88
authors = [
99
{ name = "Nathan Fulton", email = "[email protected]" },
1010
{ name = "Hendrik Strobelt", email = "[email protected]" },
@@ -17,7 +17,7 @@ authors = [
1717
]
1818
description = "mellea is a library for writing generative programs"
1919
readme = "README.md"
20-
requires-python = ">=3.11"
20+
requires-python = ">=3.10"
2121
classifiers = [
2222
"Programming Language :: Python :: 3",
2323
"License :: OSI Approved :: Apache Software License",
@@ -95,7 +95,7 @@ sphinx = [
9595
]
9696

9797
[tool.ruff]
98-
target-version = "py312"
98+
target-version = "py310"
9999
respect-gitignore = true
100100

101101
[tool.ruff.format]

0 commit comments

Comments
 (0)