mirror of
https://github.com/kennethreitz/instructor.git
synced 2026-06-05 22:50:18 +00:00
doc: move provider examples to hub (#449)
Co-authored-by: Jason Liu <jxnl@users.noreply.github.com> Co-authored-by: Jason Liu <jason@jxnl.co>
This commit is contained in:
+4
-4
@@ -18,10 +18,10 @@ The goal of the blog is to capture some content that does not neatly fit within
|
||||
|
||||
## Integrations
|
||||
|
||||
- [Ollama](posts/ollama.md)
|
||||
- [llama-cpp-python](posts/llama-cpp-python.md)
|
||||
- [Anyscale](posts/anyscale.md)
|
||||
- [Together Compute](posts/together.md)
|
||||
- [Ollama](./../hub/ollama.md)
|
||||
- [llama-cpp-python](./../hub/llama-cpp-python.md)
|
||||
- [Anyscale](./../hub/anyscale.md)
|
||||
- [Together Compute](./../hub/together.md)
|
||||
|
||||
## Media
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ Instructor's patch enhances a openai api it with the following features:
|
||||
|
||||
!!! note "Learn More"
|
||||
|
||||
To learn more, please refer to the [docs](../../index.md). To understand the benefits of using Pydantic with Instructor, visit the tips and tricks section of the [why use Pydantic](../../why.md) page.
|
||||
To learn more, please refer to the [docs](../index.md). To understand the benefits of using Pydantic with Instructor, visit the tips and tricks section of the [why use Pydantic](../why.md) page.
|
||||
|
||||
## Anyscale
|
||||
|
||||
@@ -42,7 +42,7 @@ Let's explore one of the models available in Anyscale's extensive collection!
|
||||
```python
|
||||
from openai import OpenAI
|
||||
from pydantic import BaseModel
|
||||
|
||||
import os
|
||||
import instructor
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class UserDetails(BaseModel):
|
||||
client = instructor.patch(
|
||||
OpenAI(
|
||||
base_url="https://api.endpoints.anyscale.com/v1",
|
||||
api_key="<YOUR_ANYSCALE_API_KEY>",
|
||||
api_key=os.environ["ANYSCALE_API_KEY"],
|
||||
),
|
||||
# This uses Anyscale's json schema output mode
|
||||
mode=instructor.Mode.JSON_SCHEMA,
|
||||
@@ -70,6 +70,7 @@ resp = client.chat.completions.create(
|
||||
response_model=UserDetails,
|
||||
)
|
||||
print(resp)
|
||||
#> name='Jason' age=20
|
||||
# # > name='Jason' age=20
|
||||
```
|
||||
|
||||
@@ -23,7 +23,7 @@ Instructor's patch enhances an create call it with the following features:
|
||||
|
||||
!!! note "Learn More"
|
||||
|
||||
To learn more, please refer to the [docs](../../index.md). To understand the benefits of using Pydantic with Instructor, visit the tips and tricks section of the [why use Pydantic](../../why.md) page. If you want to check out examples of using Pydantic with Instructor, visit the [examples](../../examples/index.md) page.
|
||||
To learn more, please refer to the [docs](../index.md). To understand the benefits of using Pydantic with Instructor, visit the tips and tricks section of the [why use Pydantic](../why.md) page. If you want to check out examples of using Pydantic with Instructor, visit the [examples](../examples/index.md) page.
|
||||
|
||||
## llama-cpp-python
|
||||
|
||||
@@ -47,14 +47,15 @@ llama = llama_cpp.Llama(
|
||||
n_gpu_layers=-1,
|
||||
chat_format="chatml",
|
||||
n_ctx=2048,
|
||||
draft_model=LlamaPromptLookupDecoding(num_pred_tokens=2), #(1)!
|
||||
draft_model=LlamaPromptLookupDecoding(num_pred_tokens=2), # (1)!
|
||||
logits_all=True,
|
||||
verbose=False
|
||||
verbose=False,
|
||||
)
|
||||
|
||||
|
||||
create = instructor.patch(
|
||||
create=llama.create_chat_completion_openai_v1, mode=instructor.Mode.JSON_SCHEMA #(2)!
|
||||
create=llama.create_chat_completion_openai_v1,
|
||||
mode=instructor.Mode.JSON_SCHEMA, # (2)!
|
||||
)
|
||||
|
||||
|
||||
@@ -92,7 +93,7 @@ class MeetingInfo(BaseModel):
|
||||
|
||||
|
||||
extraction_stream = create(
|
||||
response_model=instructor.Partial[MeetingInfo], #(3)!
|
||||
response_model=instructor.Partial[MeetingInfo], # (3)!
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
@@ -107,7 +108,7 @@ console = Console()
|
||||
|
||||
for extraction in extraction_stream:
|
||||
obj = extraction.model_dump()
|
||||
console.clear() #(4)!
|
||||
console.clear() # (4)!
|
||||
console.print(obj)
|
||||
```
|
||||
|
||||
@@ -116,4 +117,4 @@ We use LlamaPromptLookupDecoding to speed up structured output generation using
|
||||
3. We use `instructor.Partial` to stream out partial models.
|
||||
4. This is just a simple example of how to stream out partial models and clear the console.
|
||||
|
||||

|
||||

|
||||
@@ -26,7 +26,7 @@ Instructor's patch enhances a openai api it with the following features:
|
||||
|
||||
!!! note "Learn More"
|
||||
|
||||
To learn more, please refer to the [docs](../../index.md). To understand the benefits of using Pydantic with Instructor, visit the tips and tricks section of the [why use Pydantic](../../why.md) page.
|
||||
To learn more, please refer to the [docs](../index.md). To understand the benefits of using Pydantic with Instructor, visit the tips and tricks section of the [why use Pydantic](../why.md) page.
|
||||
|
||||
## Ollama
|
||||
|
||||
@@ -31,7 +31,7 @@ Instructor's patch enhances the openai api it with the following features:
|
||||
|
||||
!!! note "Learn More"
|
||||
|
||||
To learn more, please refer to the [docs](../../index.md). To understand the benefits of using Pydantic with Instructor, visit the tips and tricks section of the [why use Pydantic](../../why.md) page.
|
||||
To learn more, please refer to the [docs](../index.md). To understand the benefits of using Pydantic with Instructor, visit the tips and tricks section of the [why use Pydantic](../why.md) page.
|
||||
|
||||
## Together AI
|
||||
|
||||
+4
-4
@@ -21,10 +21,10 @@ Check us out in [Typescript](https://instructor-ai.github.io/instructor-js/) and
|
||||
|
||||
Including but not limited to:
|
||||
|
||||
- [Together](./blog/posts/together.md)
|
||||
- [Ollama](./blog/posts/ollama.md)
|
||||
- [AnyScale](./blog/posts/anyscale.md)
|
||||
- [llama-cpp-python](./blog/posts/llama-cpp-python.md)
|
||||
- [Together](./hub/together.md)
|
||||
- [Ollama](./hub/ollama.md)
|
||||
- [AnyScale](./hub/anyscale.md)
|
||||
- [llama-cpp-python](./hub/llama-cpp-python.md)
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
+10
@@ -168,6 +168,10 @@ nav:
|
||||
- Introducing Instructor Hub: 'hub/index.md'
|
||||
- Single Classification Model: 'hub/single_classification.md'
|
||||
- Multiple Classification Model: 'hub/multiple_classification.md'
|
||||
- Ollama: 'hub/ollama.md'
|
||||
- Llama CPP: 'hub/llama-cpp-python.md'
|
||||
- Together: 'hub/together.md'
|
||||
- Anyscale: 'hub/anyscale.md'
|
||||
- Tutorials:
|
||||
- Tutorials (Notebooks): 'tutorials/1-introduction.ipynb'
|
||||
- Tips and Tricks: 'tutorials/2-tips.ipynb'
|
||||
@@ -216,6 +220,12 @@ plugins:
|
||||
- categories
|
||||
- tags
|
||||
enabled: !ENV [CI, false]
|
||||
- redirects:
|
||||
redirect_maps:
|
||||
'blog/posts/ollama.md': 'hub/ollama.md'
|
||||
'blob/posts/llama-cpp-python.md': 'hub/llama-cpp-python.md'
|
||||
'blog/posts/together.md': 'hub/together.md'
|
||||
'blog/posts/anyscale.md': 'hub/anyscale.md'
|
||||
extra:
|
||||
analytics:
|
||||
provider: google
|
||||
|
||||
Generated
+18
-1
@@ -1563,6 +1563,24 @@ htmlmin2 = ">=0.1.13"
|
||||
jsmin = ">=3.0.1"
|
||||
mkdocs = ">=1.4.1"
|
||||
|
||||
[[package]]
|
||||
name = "mkdocs-redirects"
|
||||
version = "1.2.1"
|
||||
description = "A MkDocs plugin for dynamic page redirects to prevent broken links."
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
{file = "mkdocs-redirects-1.2.1.tar.gz", hash = "sha256:9420066d70e2a6bb357adf86e67023dcdca1857f97f07c7fe450f8f1fb42f861"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
mkdocs = ">=1.1.1"
|
||||
|
||||
[package.extras]
|
||||
dev = ["autoflake", "black", "isort", "pytest", "twine (>=1.13.0)"]
|
||||
release = ["twine (>=1.13.0)"]
|
||||
test = ["autoflake", "black", "isort", "pytest"]
|
||||
|
||||
[[package]]
|
||||
name = "mkdocs-rss-plugin"
|
||||
version = "1.12.0"
|
||||
@@ -3427,4 +3445,3 @@ multidict = ">=4.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "8a8af75e70138f0eb799bbb22def7e4d69e29a3b85b66f7d5b50c1096114cf79"
|
||||
|
||||
@@ -36,6 +36,7 @@ pytest-examples = "^0.0.10"
|
||||
mkdocs-jupyter = "^0.24.6"
|
||||
mkdocs-rss-plugin = "^1.12.0"
|
||||
mkdocs-minify-plugin = "^0.8.0"
|
||||
mkdocs-redirects = "^1.2.1"
|
||||
|
||||
[tool.poetry.group.test-docs.dependencies]
|
||||
fastapi = "^0.109.2"
|
||||
|
||||
@@ -4,6 +4,12 @@ from pytest_examples import find_examples, CodeExample, EvalExample
|
||||
|
||||
@pytest.mark.parametrize("example", find_examples("docs/hub"), ids=str)
|
||||
def test_format_blog(example: CodeExample, eval_example: EvalExample):
|
||||
if "ollama" in example.source:
|
||||
return
|
||||
|
||||
if "llama_cpp" in example.source:
|
||||
return
|
||||
|
||||
if eval_example.update_examples:
|
||||
eval_example.format(example)
|
||||
eval_example.run_print_update(example)
|
||||
|
||||
Reference in New Issue
Block a user