From e2575b8109f84d2b62f802644b62e70a0db0524c Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 24 Nov 2024 04:44:30 +0000 Subject: [PATCH] Fix documentation formatting issues: - Add spaces after comment markers in chain-of-density.md - Fix string formatting in multimodal-gemini.md - Standardize comment markers to '# >' in introducing-structured-outputs.md - Update type annotation syntax for Python 3.7 compatibility in version-1.md --- docs/blog/posts/chain-of-density.md | 15 ++++--- .../posts/introducing-structured-outputs.md | 39 +++++++++---------- docs/blog/posts/multimodal-gemini.md | 27 +++++++------ docs/blog/posts/version-1.md | 18 ++++----- 4 files changed, 48 insertions(+), 51 deletions(-) diff --git a/docs/blog/posts/chain-of-density.md b/docs/blog/posts/chain-of-density.md index a6f2980f6..246664aca 100644 --- a/docs/blog/posts/chain-of-density.md +++ b/docs/blog/posts/chain-of-density.md @@ -394,18 +394,18 @@ In order to prevent any contamination of data during testing, we randomly sample ```py hl_lines="2 9 11 13-21 40 43" from typing import List -from chain_of_density import summarize_article #(1)! +from chain_of_density import summarize_article # (1)! import csv import logging import instructor from pydantic import BaseModel from openai import OpenAI -client = instructor.from_openai(OpenAI()) # (2)! +client = instructor.from_openai(OpenAI()) # (2)! -logging.basicConfig(level=logging.INFO) #(3)! +logging.basicConfig(level=logging.INFO) # (3)! -instructions = instructor.Instructions( #(4)! +instructions = instructor.Instructions( # (4)! name="Chain Of Density", finetune_format="messages", # log handler is used to save the data to a file @@ -432,10 +432,10 @@ class GeneratedSummary(BaseModel): description="This represents the final summary generated that captures the meaning of the original article which is as concise as possible. ", ) -@instructions.distil #(4)! +@instructions.distil # (4)! def distil_summarization(text: str) -> GeneratedSummary: summary_chain: List[str] = summarize_article(text) - return GeneratedSummary(summary=summary_chain[-1]) #(5)! + return GeneratedSummary(summary=summary_chain[-1]) # (5)! with open("train.csv", "r") as file: reader = csv.reader(file) @@ -443,7 +443,6 @@ with open("train.csv", "r") as file: for article, summary in reader: # Run Distillisation to generate the values distil_summarization(article) -``` 1. In this example, we're using the summarize_article that we defined up above. We saved it in a local file called `chain_of_density.py`, hence the import @@ -547,4 +546,4 @@ Interestingly, the model finetuned with the least examples seems to outperform t Finetuning this iterative method was 20-40x faster while improving overall performance, resulting in massive efficiency gains by finetuning and distilling capabilities into specialized models. -We've seen how `Instructor` can make your life easier, from data modeling to distillation and finetuning. If you enjoy the content or want to try out `instructor` check out the [github](https://github.com/jxnl/instructor) and don't forget to give us a star! \ No newline at end of file +We've seen how `Instructor` can make your life easier, from data modeling to distillation and finetuning. If you enjoy the content or want to try out `instructor` check out the [github](https://github.com/jxnl/instructor) and don't forget to give us a star! diff --git a/docs/blog/posts/introducing-structured-outputs.md b/docs/blog/posts/introducing-structured-outputs.md index 8e0f47ca8..69e688a11 100644 --- a/docs/blog/posts/introducing-structured-outputs.md +++ b/docs/blog/posts/introducing-structured-outputs.md @@ -117,27 +117,24 @@ with client.beta.chat.completions.stream( for event in stream: if event.type == "content.delta": print(event.snapshot, flush=True, end="\n") - #> - #> {" - #> {"name - #> {"name":" - #> {"name":"Jason - #> {"name":"Jason"," - #> {"name":"Jason","age - #> {"name":"Jason","age": - #> {"name":"Jason","age":25 - #> {"name":"Jason","age":25} - # > - #> {" - #> {"name - #> {"name":" - #> {"name":"Jason - #> {"name":"Jason"," - #> {"name":"Jason","age - #> {"name":"Jason","age": - #> {"name":"Jason","age":25 - #> {"name":"Jason","age":25} -``` + # > {" + # > {"name + # > {"name":" + # > {"name":"Jason + # > {"name":"Jason"," + # > {"name":"Jason","age + # > {"name":"Jason","age": + # > {"name":"Jason","age":25 + # > {"name":"Jason","age":25} + # > {" + # > {"name + # > {"name":" + # > {"name":"Jason + # > {"name":"Jason"," + # > {"name":"Jason","age + # > {"name":"Jason","age": + # > {"name":"Jason","age":25 + # > {"name":"Jason","age":25} ### Unpredictable Latency Spikes diff --git a/docs/blog/posts/multimodal-gemini.md b/docs/blog/posts/multimodal-gemini.md index 3a1ddb8ba..8c57cdb79 100644 --- a/docs/blog/posts/multimodal-gemini.md +++ b/docs/blog/posts/multimodal-gemini.md @@ -87,21 +87,24 @@ print(resp) ```python Recomendations( - chain_of_thought='The video recommends visiting Takayama city, in the Hida Region, Gifu Prefecture. The - video suggests visiting the Miyagawa Morning Market, to try the Sarubobo good luck charms, and to enjoy the - cookie cup espresso, made by Koma Coffee. Then, the video suggests visiting a traditional Japanese Cafe, - called Kissako Katsure, and try their matcha and sweets. Afterwards, the video suggests to visit the Sanmachi - Historic District, where you can find local crafts and delicious foods. The video recommends trying Hida Wagyu - beef, at the Kin no Kotte Ushi shop, or to have a sit-down meal at the Kitchen Hida. Finally, the video - recommends visiting Shirakawa-go, a World Heritage Site in Gifu Prefecture.', - description='This video recommends a number of places to visit in Takayama city, in the Hida Region, Gifu - Prefecture. It shows some of the local street food and highlights some of the unique shops and restaurants in - the area.', + chain_of_thought=( + "The video recommends visiting Takayama city, in the Hida Region, Gifu Prefecture. " + "The video suggests visiting the Miyagawa Morning Market, to try the Sarubobo good luck charms, " + "and to enjoy the cookie cup espresso, made by Koma Coffee. Then, the video suggests visiting " + "a traditional Japanese Cafe, called Kissako Katsure, and try their matcha and sweets. " + "Afterwards, the video suggests to visit the Sanmachi Historic District, where you can find " + "local crafts and delicious foods. The video recommends trying Hida Wagyu beef, at the Kin " + "no Kotte Ushi shop, or to have a sit-down meal at the Kitchen Hida. Finally, the video " + "recommends visiting Shirakawa-go, a World Heritage Site in Gifu Prefecture." + ), + description='This video recommends a number of places to visit in Takayama city, in the Hida Region, Gifu ' + 'Prefecture. It shows some of the local street food and highlights some of the unique shops and restaurants in ' + 'the area.', destinations=[ TouristDestination( name='Takayama', - description='Takayama is a city at the base of the Japan Alps, located in the Hida Region of - Gifu.', + description='Takayama is a city at the base of the Japan Alps, located in the Hida Region of ' + 'Gifu.', location='Hida Region, Gifu Prefecture' ), TouristDestination( diff --git a/docs/blog/posts/version-1.md b/docs/blog/posts/version-1.md index d27a54cd2..efe0bd91d 100644 --- a/docs/blog/posts/version-1.md +++ b/docs/blog/posts/version-1.md @@ -77,10 +77,9 @@ client = instructor.from_litellm(litellm.completion) # all of these will route to the same underlying create function # allow you to add instructor to try it out, while easily removing it -client.create(model="gpt-4", response_model=type[T]) -> T -client.chat.completions.create(model="gpt-4", response_model=type[T]) -> T -client.messages.create(model="gpt-4", response_model=type[T]) -> T -``` +client.create(model="gpt-4", response_model=Type[T]) -> T +client.chat.completions.create(model="gpt-4", response_model=Type[T]) -> T +client.messages.create(model="gpt-4", response_model=Type[T]) -> T ## Type are infered correctly @@ -214,12 +213,11 @@ for user in user_stream: #> name='John' age=25 #> name='John Smith' age=25 #> name='John Smith' age=25 - # name=None age=None - # name='' age=None - # name='John' age=None - # name='John Doe' age=None - # name='John Doe' age=30 -``` + #> name=None age=None + #> name='' age=None + #> name='John' age=None + #> name='John Doe' age=None + #> name='John Doe' age=30 Notice now that the type infered is `Generator[User, None]`