Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Bug Report
about: Report a bug encountered while using
title: ''
labels: bug
assignees: ''

---

<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!
-->

**What happened**:

**What you expected to happen**:

**How to reproduce it (as minimally and precisely as possible)**:

**Anything else we need to know?**:

**Environment**:
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/CLEANUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Clean Up Request
about: Suggest to clean up code, process or tech debt to the project
title: ''
labels: cleanup
assignees: ''

---

<!-- Please only use this template for submitting clean up requests -->

**What would you like to be cleaned**:

**Why is this needed**:
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Feature Request
about: Suggest a feature to the project
title: ''
labels: feature
assignees: ''

---

<!-- Please only use this template for submitting feature requests -->

**What would you like to be added**:

**Why is this needed**:

**Completion requirements**:

This feature requires the following artifacts:

- [ ] Design doc
- [ ] API change
- [ ] Docs update

The artifacts should be linked in subsequent comments.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: New Release
about: Propose a new release
title: Release v0.x.0
labels: ''
assignees: ''

---

## Release Checklist
<!--
Please do not remove items from the checklist
-->
- [ ] Verify that the changelog in this issue is up-to-date
- [ ] Bump the version number in `pyproject.toml` to the new version (e.g., v0.x.0)
- [ ] Merge the PR that bumps the version number
- [ ] For major or minor releases (v$MAJ.$MIN.0), create a new release branch.
- [ ] an OWNER creates a vanilla release branch with
`git branch release-$MAJ.$MIN.0 main`
- [ ] An OWNER pushes the new release branch with
`git push --set-upstream upstream release-$MAJ.$MIN.0`
- [ ] An OWNER [prepares a draft release](https://github.com/inftyai/amrs/releases)
- [ ] Write the change log into the draft release.
- [ ] Don't release the draft yet.
- [ ] Publish the release to PyPI
- [ ] run `make build` to build the package
- [ ] run `make publish` to publish the package to PyPI
- [ ] Publish the draft release prepared at the [Github releases page](https://github.com/inftyai/amrs/releases).
- [ ] Close this issue


## Changelog
<!--
Describe changes since the last release here.
-->
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Support Request
about: Support request or question relating to the project
title: ''
labels: support
assignees: ''

---
21 changes: 21 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#### What this PR does / why we need it

#### Which issue(s) this PR fixes
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #

#### Special notes for your reviewer

#### Does this PR introduce a user-facing change?
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note

```
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ __pycache__
/temp/

dist/


# Added by cargo

/target
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "AMRS"
version = "0.1.0"
edition = "2024"

[dependencies]
7 changes: 7 additions & 0 deletions amrs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from amrs.config import ModelConfig, Config, RoutingMode

__all__ = [
"ModelConfig",
"Config",
"RoutingMode",
]
62 changes: 62 additions & 0 deletions amrs/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from enum import Enum
from typing import Callable
from pydantic import BaseModel, Field, model_validator
from typing import List, Optional

class BasicModelConfig(BaseModel):
base_url: Optional[str] = Field(
default=None,
description="Global base URL for model API endpoints."
)
temperature: Optional[float] = Field(
default=0.8,
description="Global temperature setting for model generation."
)

class ModelConfig(BasicModelConfig):
id: str = Field(
description="ID of the model, including both the provider name and the model name, e.g. 'openai:gpt-4'."
)
weight: Optional[int] = Field(
default=1,
description="Weight of the model for ensemble methods. Only used if routing_mode is 'weighted'."
)

class ChatRole(str, Enum):
USER = "user"
ASSISTANT = "assistant"
SYSTEM = "system"

class Message(BaseModel):
role: ChatRole = Field(description="Role of the message sender.")
# For image messages, the format is different, but we only support text message for now.
# See https://platform.openai.com/docs/api-reference/chat/create
content: str = Field(description="Content of the message.")

class RoutingMode(str, Enum):
RANDOM = "random"
WEIGHTED = "weighted"

class Config(BasicModelConfig):
models: List[ModelConfig] = Field(description="List of model configurations")
routing_mode: RoutingMode = Field(
default=RoutingMode.RANDOM,
description="Routing mode for the model, default is random.",
)
callback_funcs: Optional[List[Callable]] = Field(
default=None,
description="Callback functions to be called after each model inference. Functions will be called sequentially.",
)
messages: str | List[Message] = Field(
description="Messages to be sent to the model(s). Can be a string or a list of Message objects."
)

@model_validator(mode="after")
def ensure_at_least_one_base_url(self):
global_url_exist = self.base_url is not None

for model in self.models:
if not model.base_url and not global_url_exist:
raise ValueError("At least one base_url must be specified either in the global config or in each model config.")

return self
Empty file added amrs/store/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions amrs/store/store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Store:
pass
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ license = {text = "MIT License"}
readme = "README.md"
requires-python = ">=3.12"

dependencies = []
dependencies = [
"pydantic>=2.12.4",
]

[dependency-groups]
dev = [
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
25 changes: 25 additions & 0 deletions tests/unit/config_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from amrs.config import ModelConfig, Config

def test_config():
config = Config(
base_url="https://api.example.com",
temperature=0.7,
models=[
ModelConfig(
id="openai:gpt-4",
weight=20,
temperature=0.5
),
ModelConfig(
id="anthropic:claude-2",
weight=80,
base_url="https://api.anthropic.com"
)
],
routing_mode="weighted",
messages=[
{"role": "user", "content": "Hello, how are you?"}
]
)

assert config.base_url == "https://api.example.com"
Loading
Loading