-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a devcontainer with Redis and a Ollama server (#217)
* minimal demo example of running custom model * devcontainer setup and example * remove default_bad_process_model to allow using custom model entirely * improve the demo to show parallel execution * CI: update tests trigger from pull request target to pull request * fix mypy errors * adding stubs to pyproject.toml * poetry lock * install all extras in the devcontainer start script * add dev containers instruction * add a link to command palette wiki * adding instructions for dev containers
- Loading branch information
Showing
8 changed files
with
1,387 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/python | ||
{ | ||
"name": "Sotopia Place", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", | ||
"features": { | ||
"ghcr.io/itsmechlark/features/redis-server:1": {}, | ||
"ghcr.io/prulloac/devcontainer-features/ollama:1": {} | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "pipx install poetry; poetry install --all-extras; ollama pull llama3.2:1b" | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ on: | |
- main | ||
- release | ||
- dev | ||
pull_request_target: | ||
pull_request: | ||
branches: | ||
- main | ||
- release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Example: Generate (2~7) random numbers using Llama3.2 model served by ollama | ||
# To run this example, you can either | ||
# 1. Use the sotopia devcontainer and run the following command in the terminal: | ||
# poetry run python examples/generation_api/custom_model.py | ||
# This example can also serve a sanity check for your devcontainer setup. | ||
# OR 2. after installing sotopia, install ollama, and then: | ||
# ollama pull llama3.2:1b; python examples/generation_api/custom_model.py | ||
# OR 3. after installing sotopia, serve your desired model on your desired port, | ||
# and then change the model_name of `agenerate` to point to your desired model. | ||
# Finally: | ||
# python examples/generation_api/custom_model.py | ||
# Expected output for (1 and 2): a bunch of logs and an output [[14, 67], [6, 8, 3], [6, 8, 3, 9], [6, 8, 3, 9, 7], [7, 9, 6, 8, 4, 1]] | ||
|
||
from sotopia.generation_utils.generate import ListOfIntOutputParser, agenerate | ||
import logging | ||
|
||
# Set logging to the lowest level to show all logs | ||
logging.basicConfig(level=0) | ||
|
||
|
||
async def generate_n_random_numbers(n: int) -> list[int]: | ||
return await agenerate( | ||
model_name="custom/llama3.2:1b@http://localhost:11434/v1", | ||
template="Generate {n} random integer numbers. {format_instructions}", | ||
input_values={"n": str(n)}, | ||
temperature=0.0, | ||
output_parser=ListOfIntOutputParser(n), | ||
) | ||
|
||
|
||
async def main() -> None: | ||
random_numbers = await asyncio.gather( | ||
*[generate_n_random_numbers(n) for n in range(2, 7)] | ||
) | ||
print(random_numbers) | ||
|
||
|
||
if __name__ == "__main__": | ||
import asyncio | ||
|
||
asyncio.run(main()) |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters