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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user