bump docs

This commit is contained in:
Jason Liu
2024-02-05 16:51:48 -05:00
parent dcb84b1301
commit 07524a4c65
9 changed files with 103 additions and 6695 deletions
+7 -1
View File
@@ -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)
+2 -2
View File
@@ -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.
+1 -1
View File
@@ -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
+1 -1
View File
@@ -88,7 +88,7 @@ print(user2.model_dump_json(indent=2))
"""
{
"result": null,
"error": false,
"error": true,
"message": "Unknown user"
}
"""
+3
View File
@@ -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(
@@ -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)
+84 -6685
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -25,7 +25,7 @@ user: UserExtract = client.chat.completions.create(
print(user._raw_response)
"""
ChatCompletion(
id='chatcmpl-8oz1eZxBVDCUZu7Q247DenDK8T3ji',
id='chatcmpl-8p1AMuoml2bkdXK4284rbPmNRNNwF',
choices=[
Choice(
finish_reason='stop',
@@ -42,7 +42,7 @@ ChatCompletion(
),
)
],
created=1707161674,
created=1707169902,
model='gpt-3.5-turbo-0613',
object='chat.completion',
system_fingerprint=None,
+1 -1
View File
@@ -169,7 +169,7 @@ model = client.chat.completions.create(
print(model.model_dump_json(indent=2))
"""
{
"name": "jason",
"name": "Jason",
"age": 25
}
"""
+2 -2
View File
@@ -120,7 +120,7 @@ print(response.model_dump_json(indent=2))
print(user._raw_response.model_dump_json(indent=2))
"""
{
"id": "chatcmpl-8oz12FZ9fvCypa8yNuKbHXueJQkOv",
"id": "chatcmpl-8p19pXZ5BIqGtaPhVLo184UuQNH3v",
"choices": [
{
"finish_reason": "stop",
@@ -137,7 +137,7 @@ print(response.model_dump_json(indent=2))
}
}
],
"created": 1707161636,
"created": 1707169869,
"model": "gpt-3.5-turbo-0613",
"object": "chat.completion",
"system_fingerprint": null,