Contribution guide
We welcome contributions from every respectful contributor!
Loading actions...
Skill content
Main instructions and any bundled files for this skill.
Contribution guide
We welcome contributions from every respectful contributor!
There are multiple ways you can contribute to phospho:
- Help us address bugs and new features by opening an Issue on Github
- Reach out by mail
- Engage in the community on Discord
- Enhance the phospho package by adding new evaluation jobs to the
job_library
This guide will focus on how to add jobs to the phospho library.
Setup
Requirements
- Python 3.9 or higher
- Poetry for packaging and dependency management
Install poetry and the phospho project:
curl -sSL https://install.python-poetry.org | python3 -
cd phospho-python
poetry install
Guide: How to create a job?
Create a new job in phospho-python/lab/job_library.py by taking an existing job as an example.
# A Job is a function that takes as first parameter a Message and that returns a JobResult
# Additional parameters can be specified
def prompt_to_bool(
message: Message,
prompt: str,
format_kwargs: Optional[dict] = None,
model: str = "gpt-3.5-turbo",
) -> JobResult:
"""
Runs a prompt on a message and returns a boolean result.
"""
# Call any LLM models or API in the job
openai_model = OpenAIModel(config.OPENAI_API_KEY, model)
if format_kwargs is None:
format_kwargs = {}
formated_prompt = prompt.format(
message_content=message.content,
message_context=message.previous_messages_transcript(with_role=True),
**format_kwargs,
)
llm_response = openai_model.invoke(formated_prompt).strip()
if llm_response is None:
bool_response = False
else:
bool_response = llm_response.lower() == "true"
# Return a JobResult
return JobResult(
job_id="prompt_to_bool",
result_type=ResultType.bool,
value=bool_response,
logs=[formated_prompt, llm_response],
)
Using this framework will allow the job to be compatible with the .optimize method (to figure out the best set of parameters) and the exported results (to store the analytics in a standard way).
Testing
We use pytest for testing. Test files are located in the phospho-python/tests folder. To run the tests, use the following command:
poetry run pytest
Building locally
To build the package locally, run :
poetry build
You can then import the built package (even in a different project and environment) using (replace with the path to the actual file) :
pip install path/to/dist/phospho-0.1.0.tar.gz
You can also test your dockerfiles locally by running
docker build -t <name ie frontend, backend, etc...> .
or
docker build --file <./filename> -t <name ie frontend, backend, etc...> .
Running temporal locally
temporal server start-dev --db-filename your_temporal.db --ui-port 8080
Pull Requests
In github, create a Pull Request targeting the dev branch.
Publishing
Publishing is handled by Github Actions when maintainers create a new release.
- Create a new Release in Github. As a tag, use the same version as in
pyproject.toml - Tick the pre-release box to deploy to test pypi. Don't tick it to deploy to the main pypi.
Related Skills
Frontend Typescript Linting.mdc
TypeScript and ESLint rules that MUST be followed when creating, modifying, or reviewing any file under apps/frontend/, including .ts, .tsx, .js, and .jsx files. Also apply when discussing frontend li...
2. Apply Deepthink Protocol (reason about dependencies
risks