Skip to content

Commit

Permalink
bump docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnl committed Feb 5, 2024
1 parent dcb84b1 commit 07524a4
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 6,695 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,13 @@ model = client.chat.completions.create(
],
)

assert model.name == "JASON"
print(model.model_dump_json(indent=2))
"""
{
"name": "JASON",
"age": 25
}
"""
```

## [Evals](https://github.com/jxnl/instructor/tree/main/tests/openai/evals)
Expand Down
4 changes: 2 additions & 2 deletions docs/concepts/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def extract(data) -> UserDetail:
start = time.perf_counter() # (1)
model = extract("Extract jason is 25 years old")
print(f"Time taken: {time.perf_counter() - start}")
#> Time taken: 0.6282629589550197
#> Time taken: 0.44677383406087756

start = time.perf_counter()
model = extract("Extract jason is 25 years old") # (2)
print(f"Time taken: {time.perf_counter() - start}")
#> Time taken: 1.9171275198459625e-06
#> Time taken: 1.00000761449337e-06
```

1. Using `time.perf_counter()` to measure the time taken to run the function is better than using `time.time()` because it's more accurate and less susceptible to system clock changes.
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def print_iterable_results():
async for m in model:
print(m)
#> name='John Doe' age=30
#> name='Jane Smith' age=25
#> name='Jane Doe' age=28


import asyncio
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/maybe.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ print(user2.model_dump_json(indent=2))
"""
{
"result": null,
"error": false,
"error": true,
"message": "Unknown user"
}
"""
Expand Down
3 changes: 3 additions & 0 deletions docs/concepts/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class SearchQuery(BaseModel):
def execute(self):
print(f"Searching for {self.query} of type {self.query_type}")
#> Searching for cat of type image
return "Results for cat"


query = client.chat.completions.create(
Expand All @@ -160,6 +161,8 @@ query = client.chat.completions.create(
)

results = query.execute()
print(results)
#> Results for cat
```

Now we can call `execute` on our model instance after extracting it from a language model. If you want to see more examples of this checkout our post on [RAG is more than embeddings](../blog/posts/rag-and-beyond.md)
Loading

0 comments on commit 07524a4

Please sign in to comment.