(no commit message)
This commit is contained in:
5
auto_classes.json
Normal file
5
auto_classes.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"AutoConfig": "program.config.AgentWRetreiverConfig",
|
||||
"AutoProgram": "program.program.AgentWRetreiver",
|
||||
"AutoRetriever": "program.retriever.ExampleRetriever"
|
||||
}
|
||||
15
config.json
Normal file
15
config.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"model": null,
|
||||
"num_fetch": 1,
|
||||
"lm": "openai/gpt-4o-mini",
|
||||
"embedder": "openai/text-embedding-3-small",
|
||||
"clients": {
|
||||
"mit": [
|
||||
"csail",
|
||||
"mit-media-lab"
|
||||
],
|
||||
"berkeley": [
|
||||
"bear"
|
||||
]
|
||||
}
|
||||
}
|
||||
9
program.json
Normal file
9
program.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"metadata": {
|
||||
"dependency_versions": {
|
||||
"python": "3.13",
|
||||
"dspy": "3.1.2",
|
||||
"cloudpickle": "3.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
0
program/__init__.py
Normal file
0
program/__init__.py
Normal file
13
program/compile.py
Normal file
13
program/compile.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import sys
|
||||
|
||||
from .config import AgentWRetreiverConfig
|
||||
from .program import AgentWRetreiver
|
||||
from .retriever import ExampleRetriever
|
||||
|
||||
if __name__ == "__main__":
|
||||
username = sys.argv[1] # ← first arg after script name (username)
|
||||
config = AgentWRetreiverConfig(num_fetch=1)
|
||||
retriever = ExampleRetriever(config, needed_param="hi")
|
||||
agent = AgentWRetreiver(config, retriever=retriever)
|
||||
repo_path = f"{username}/nested_repo"
|
||||
agent.push_to_hub(repo_path, with_code=True)
|
||||
10
program/config.py
Normal file
10
program/config.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from pydantic import Field
|
||||
|
||||
from modaic import PrecompiledConfig
|
||||
|
||||
|
||||
class AgentWRetreiverConfig(PrecompiledConfig):
|
||||
num_fetch: int
|
||||
lm: str = "openai/gpt-4o-mini"
|
||||
embedder: str = "openai/text-embedding-3-small"
|
||||
clients: dict = Field(default_factory=lambda: {"mit": ["csail", "mit-media-lab"], "berkeley": ["bear"]})
|
||||
18
program/program.py
Normal file
18
program/program.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from modaic import PrecompiledProgram
|
||||
|
||||
from .config import AgentWRetreiverConfig
|
||||
from .retriever import ExampleRetriever
|
||||
from .tools.google.google_search import search_google # noqa: F401
|
||||
from .utils.used import random_util # noqa: F401
|
||||
|
||||
|
||||
class AgentWRetreiver(PrecompiledProgram):
|
||||
config: AgentWRetreiverConfig
|
||||
|
||||
def __init__(self, config: AgentWRetreiverConfig, retriever: ExampleRetriever, **kwargs):
|
||||
super().__init__(config, retriever=retriever, **kwargs)
|
||||
self.lm = self.config.lm
|
||||
self.clients = self.config.clients
|
||||
|
||||
def forward(self, query: str) -> str:
|
||||
return self.retriever.retrieve(query)
|
||||
17
program/retriever.py
Normal file
17
program/retriever.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from modaic import Retriever
|
||||
|
||||
from .config import AgentWRetreiverConfig
|
||||
from .tools.jira.jira_api_tools import call_jira_api # noqa: F401
|
||||
from .utils.used import random_util # noqa: F401
|
||||
|
||||
|
||||
class ExampleRetriever(Retriever):
|
||||
config: AgentWRetreiverConfig
|
||||
|
||||
def __init__(self, config: AgentWRetreiverConfig, needed_param: str, **kwargs):
|
||||
super().__init__(config, **kwargs)
|
||||
self.embedder_name = config.embedder
|
||||
self.needed_param = needed_param
|
||||
|
||||
def retrieve(self, query: str) -> str:
|
||||
return f"Retrieved {self.config.num_fetch} results for {query}"
|
||||
0
program/tools/__init__.py
Normal file
0
program/tools/__init__.py
Normal file
0
program/tools/google/__init__.py
Normal file
0
program/tools/google/__init__.py
Normal file
2
program/tools/google/google_search.py
Normal file
2
program/tools/google/google_search.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def search_google() -> str:
|
||||
return "search_google"
|
||||
0
program/tools/jira/__init__.py
Normal file
0
program/tools/jira/__init__.py
Normal file
2
program/tools/jira/jira_api_tools.py
Normal file
2
program/tools/jira/jira_api_tools.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def call_jira_api() -> str:
|
||||
return "call_jira_api"
|
||||
0
program/utils/__init__.py
Normal file
0
program/utils/__init__.py
Normal file
2
program/utils/second_degree_import.py
Normal file
2
program/utils/second_degree_import.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def import_me_too() -> str:
|
||||
return "import_me_too"
|
||||
5
program/utils/used.py
Normal file
5
program/utils/used.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from .second_degree_import import import_me_too # noqa: F401
|
||||
|
||||
|
||||
def random_util() -> str:
|
||||
return "random_util"
|
||||
10
pyproject.toml
Normal file
10
pyproject.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[project]
|
||||
name = "nested_repo"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = ["dspy", "modaic"]
|
||||
|
||||
[tool.uv.sources]
|
||||
modaic = { workspace = true }
|
||||
Reference in New Issue
Block a user