gptools
This module serves as toolbox with different GPT related functions that canbe used to interact with GPT models. The functions are designed to be used
either in a stand-alone manner or in combination with other functions for
more elaborated pipelines.
Example (Rag)
no available example in current language// example on how to run a full e2e RAG model across different types of
// documents in a directory
func (m *Examples) Gptools_Rag(
ctx context.Context,
openaiApiKey *Secret,
//+default="who are the authors of the nix paper?"
question string,
) (string, error) {
nixPaper := dag.HTTP("https://edolstra.github.io/pubs/nspfssd-lisa2004-final.pdf")
foxImage := dag.HTTP("https://fsquaredmarketing.com/wp-content/uploads/2024/04/bitter-font.png")
return dag.Gptools().Rag(ctx,
openaiApiKey,
dag.Directory().
WithFile("nix-paper.pdf", nixPaper).
WithFile("image.png", foxImage),
question,
)
}async def gptools__rag(
self,
openai_api_key: dagger.Secret,
question: str,
) -> str:
"""example on how to run a full e2e RAG model across different types of
documents in a directory"""
nixPaper = dag.http(
"https://edolstra.github.io/pubs/nspfssd-lisa2004-final.pdf",
)
foxImage = dag.http(
"https://fsquaredmarketing.com/wp-content/uploads/2024/04/bitter-font.png",
)
return await dag.gptools().rag(
openai_api_key,
dag.directory()
.with_file("nix-paper.pdf", nixPaper)
.with_file("image.png", foxImage),
question,
) /**
* example on how to run a full e2e RAG model across different types of
* documents in a directory
*/
@func()
gptools_rag(openaiApiKey: Secret, question: string): Promise<string> {
const nixPaper = dag.http(
"https://edolstra.github.io/pubs/nspfssd-lisa2004-final.pdf",
);
const foxImage = dag.http(
"https://fsquaredmarketing.com/wp-content/uploads/2024/04/bitter-font.png",
);
return dag
.gptools()
.rag(
openaiApiKey,
dag
.directory()
.withFile("nix-paper.pdf", nixPaper)
.withFile("image.png", foxImage),
question,
);
}Installation
dagger install github.com/marcosnils/daggerverse/gptools@v0.0.3Entrypoint
Return Type
Gptools ! Example
dagger -m github.com/marcosnils/daggerverse/gptools@1b87e8a33e8118b5955f5ea00c43e414d514859a call \
func (m *MyModule) Example() *dagger.Gptools {
return dag.
Gptools()
}@function
def example() -> dagger.Gptools:
return (
dag.gptools()
)@func()
example(): Gptools {
return dag
.gptools()
}Types
Gptools 🔗
baseCtr() 🔗
Return Type
Container ! Example
dagger -m github.com/marcosnils/daggerverse/gptools@1b87e8a33e8118b5955f5ea00c43e414d514859a call \
base-ctrfunc (m *MyModule) Example() *dagger.Container {
return dag.
Gptools().
BaseCtr()
}@function
def example() -> dagger.Container:
return (
dag.gptools()
.base_ctr()
)@func()
example(): Container {
return dag
.gptools()
.baseCtr()
}ytctr() 🔗
Return Type
Container ! Example
dagger -m github.com/marcosnils/daggerverse/gptools@1b87e8a33e8118b5955f5ea00c43e414d514859a call \
ytctrfunc (m *MyModule) Example() *dagger.Container {
return dag.
Gptools().
Ytctr()
}@function
def example() -> dagger.Container:
return (
dag.gptools()
.ytctr()
)@func()
example(): Container {
return dag
.gptools()
.ytctr()
}yturl() 🔗
Return Type
String ! Example
dagger -m github.com/marcosnils/daggerverse/gptools@1b87e8a33e8118b5955f5ea00c43e414d514859a call \
yturlfunc (m *MyModule) Example(ctx context.Context) string {
return dag.
Gptools().
Yturl(ctx)
}@function
async def example() -> str:
return await (
dag.gptools()
.yturl()
)@func()
async example(): Promise<string> {
return dag
.gptools()
.yturl()
}rag() 🔗
Runs a RAG model on the provided source directory and question
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| openaiApiKey | Secret ! | - | No description provided |
| source | Directory ! | - | No description provided |
| question | String ! | - | No description provided |
Example
dagger -m github.com/marcosnils/daggerverse/gptools@1b87e8a33e8118b5955f5ea00c43e414d514859a call \
rag --openai-api-key env:MYSECRET --source DIR_PATH --question stringfunc (m *MyModule) Example(ctx context.Context, openaiApiKey *dagger.Secret, source *dagger.Directory, question string) string {
return dag.
Gptools().
Rag(ctx, openaiApiKey, source, question)
}@function
async def example(openai_api_key: dagger.Secret, source: dagger.Directory, question: str) -> str:
return await (
dag.gptools()
.rag(openai_api_key, source, question)
)@func()
async example(openaiApiKey: Secret, source: Directory, question: string): Promise<string> {
return dag
.gptools()
.rag(openaiApiKey, source, question)
}ytChat() 🔗
Asks a question to a youtube video
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| openaiApiKey | Secret ! | - | No description provided |
| url | String ! | - | No description provided |
| question | String ! | - | No description provided |
Example
dagger -m github.com/marcosnils/daggerverse/gptools@1b87e8a33e8118b5955f5ea00c43e414d514859a call \
yt-chat --openai-api-key env:MYSECRET --url string --question stringfunc (m *MyModule) Example(ctx context.Context, openaiApiKey *dagger.Secret, url string, question string) string {
return dag.
Gptools().
YtChat(ctx, openaiApiKey, url, question)
}@function
async def example(openai_api_key: dagger.Secret, url: str, question: str) -> str:
return await (
dag.gptools()
.yt_chat(openai_api_key, url, question)
)@func()
async example(openaiApiKey: Secret, url: string, question: string): Promise<string> {
return dag
.gptools()
.ytChat(openaiApiKey, url, question)
}transcript() 🔗
Returns the video transcript as a txt file
Return Type
File !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| src | File ! | - | No description provided |
Example
no available example in current language// example on how to return a transcript from a video file
func (m *Examples) GptoolsTranscript(
ctx context.Context,
// free to use movie https://mango.blender.org/about/
//+default="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4"
url string,
) (string, error) {
video := dag.HTTP(url)
return dag.Gptools().Transcript(video).Contents(ctx)
}async def gptools_transcript(
self,
url: str = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4",
) -> str:
"""example on how to get a transcript for a video and"""
# TODO: call transcript once python gen is fixed
# video = dag.http(url)
return await dag.gptools().audio(url).contents() /**
* example on how to return a transcript from a video file
*/
@func()
async gptoolsTranscript(
// free to use movie https://mango.blender.org/about/
url = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4",
): Promise<string> {
const video = dag.http(url);
return dag.gptools().transcript(video).contents();
}Example (Directory)
no available example in current language// example on how to get a transcript for a video and
// return it as a *Directory to use in other functions
func (m *Examples) GptoolsTranscript_Directory(
ctx context.Context,
// free to use movie https://mango.blender.org/about/
//+default="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4"
url string,
) *Directory {
video := dag.HTTP(url)
return dag.Directory().
WithFile("video-transcript.txt", dag.Gptools().Transcript(video))
}async def gptools_transcript__directory(
self,
url: str = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4",
) -> dagger.Directory:
"""example on how to get a transcript for a video and
return it as a *Directory to use in other functions"""
# TODO: call transcript once python gen is fixed
# video = dag.http(url)
return dag.directory().with_file(
"video-transcript.txt", dag.gptools().audio(url)
) /**
* example on how to get a transcript for a video and
* return it as a *Directory to use in other functions
*/
@func()
gptoolsTranscript_Directory(
// free to use movie https://mango.blender.org/about/
url = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4",
): Directory {
const video = dag.http(url);
return dag
.directory()
.withFile("video-transcript.txt", dag.gptools().transcript(video));
}audio() 🔗
Returns the video audio as an mp3 encoded file
Return Type
File !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| url | String ! | - | No description provided |
Example
dagger -m github.com/marcosnils/daggerverse/gptools@1b87e8a33e8118b5955f5ea00c43e414d514859a call \
audio --url stringfunc (m *MyModule) Example(url string) *dagger.File {
return dag.
Gptools().
Audio(url)
}@function
def example(url: str) -> dagger.File:
return (
dag.gptools()
.audio(url)
)@func()
example(url: string): File {
return dag
.gptools()
.audio(url)
}