Skip to content

Commit

Permalink
Add detail param to gpt-4v (langchain-ai#3215)
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul authored Nov 9, 2023
1 parent 6942f10 commit 0bf36f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions examples/src/models/chat/integration_openai_vision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,30 @@ console.log({ res2 });
}
}
*/

const lowDetailImage = new HumanMessage({
content: [
{
type: "text",
text: "Summarize the contents of this image.",
},
{
type: "image_url",
image_url: {
url: "https://blog.langchain.dev/content/images/size/w1248/format/webp/2023/10/Screenshot-2023-10-03-at-4.55.29-PM.png",
detail: "low",
},
},
],
});
const res3 = await chat.invoke([lowDetailImage]);
console.log({ res3 });

/*
{
res3: AIMessage {
content: 'The image shows a user interface for a service named "WebLangChain," which appears to be powered by "Twalv." It includes a text box with the prompt "Ask me anything about anything!" suggesting that users can enter questions on various topics. Below the text box, there are example questions that users might ask, such as "what is langchain?", "history of mesopotamia," "how to build a discord bot," "leonardo dicaprio girlfriend," "fun gift ideas for software engineers," "how does a prism separate light," and "what beer is best." The interface also includes a round blue button with a paper plane icon, presumably to submit the question. The overall theme of the image is dark with blue accents.',
additional_kwargs: { function_call: undefined }
}
}
*/
2 changes: 1 addition & 1 deletion langchain/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export type MessageContent =
| {
type: "text" | "image_url";
text?: string;
image_url?: string | { url: string };
image_url?: string | { url: string; detail?: "low" | "high" };
}[];

export interface BaseMessageFields {
Expand Down

0 comments on commit 0bf36f7

Please sign in to comment.