-
Notifications
You must be signed in to change notification settings - Fork 1
Support server #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Support server #44
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
95575bf
add server support
kerthcet d622695
Add logo to serve
kerthcet 9e8603d
fix tests
kerthcet ccfb4c3
fix lint
kerthcet e07923f
fix tests
kerthcet a825f3b
fix tests
kerthcet ab81570
fix test
kerthcet 70d20a2
fix lint
kerthcet 0387e38
remove libs
kerthcet d39b98f
fix tests
kerthcet 9ad99db
change log lib
kerthcet 2f3fcee
change the request log level
kerthcet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,68 @@ | ||
| # Hack Directory | ||
|
|
||
| Development and testing utilities for PUMA. | ||
|
|
||
| ## Structure | ||
|
|
||
| ``` | ||
| hack/ | ||
| └── scripts/ # Test and utility scripts | ||
| └── test_api.sh | ||
| ``` | ||
|
|
||
| ## Scripts | ||
|
|
||
| ### `scripts/test_api.sh` | ||
|
|
||
| Tests all PUMA API endpoints manually. | ||
|
|
||
| **Usage:** | ||
| ```bash | ||
| # Start PUMA server first | ||
| ./puma serve | ||
|
|
||
| # In another terminal | ||
| ./hack/scripts/test_api.sh | ||
| ``` | ||
|
|
||
| **Tests:** | ||
| - Health check | ||
| - List models | ||
| - Chat completion (non-streaming) | ||
| - Chat completion (streaming) | ||
| - Text completion | ||
|
|
||
| **Requirements:** | ||
| - Running PUMA server | ||
| - `curl` and `jq` installed | ||
|
|
||
| --- | ||
|
|
||
|
|
||
| ## Adding New Scripts | ||
|
|
||
| Place development and testing scripts in `hack/scripts/`: | ||
|
|
||
| ```bash | ||
| # Create new script | ||
| cat > hack/scripts/my_script.sh << 'EOF' | ||
| #!/bin/bash | ||
| # Your script here | ||
| EOF | ||
|
|
||
| # Make executable | ||
| chmod +x hack/scripts/my_script.sh | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Why "hack"? | ||
|
|
||
| The `hack/` directory is a convention from Kubernetes and other projects for: | ||
| - Development utilities | ||
| - Test scripts | ||
| - Build helpers | ||
| - CI/CD scripts | ||
| - One-off tools | ||
|
|
||
| It keeps the root directory clean while providing a place for development tools. |
This file contains hidden or 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,53 @@ | ||
| #!/bin/bash | ||
|
|
||
| echo "Testing PUMA OpenAI-Compatible API" | ||
| echo "====================================" | ||
| echo | ||
|
|
||
| # Base URL | ||
| BASE_URL="http://localhost:8000" | ||
|
|
||
| echo "1. Health Check" | ||
| curl -s "$BASE_URL/health" | ||
| echo -e "\n" | ||
|
|
||
| echo "2. List Models" | ||
| curl -s "$BASE_URL/v1/models" | jq '.' | ||
| echo | ||
|
|
||
| echo "3. Chat Completion (Non-streaming)" | ||
| curl -s "$BASE_URL/v1/chat/completions" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "test-model", | ||
| "messages": [ | ||
| {"role": "user", "content": "Hello!"} | ||
| ], | ||
| "max_tokens": 50 | ||
| }' | jq '.' | ||
|
kerthcet marked this conversation as resolved.
|
||
| echo | ||
|
|
||
| echo "4. Chat Completion (Streaming)" | ||
| curl -s -N "$BASE_URL/v1/chat/completions" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "test-model", | ||
| "messages": [ | ||
| {"role": "user", "content": "Tell me a story"} | ||
| ], | ||
| "stream": true, | ||
| "max_tokens": 50 | ||
| }' | ||
| echo -e "\n" | ||
|
|
||
| echo "5. Legacy Text Completion" | ||
| curl -s "$BASE_URL/v1/completions" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "test-model", | ||
| "prompt": "Once upon a time", | ||
| "max_tokens": 50 | ||
| }' | jq '.' | ||
|
kerthcet marked this conversation as resolved.
|
||
| echo | ||
|
|
||
| echo "Done!" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.