From dd3abccc5037144541f5e04f1c3a2ad889dae7b9 Mon Sep 17 00:00:00 2001 From: Richard Weerasinghe Date: Tue, 27 Aug 2024 10:23:49 +1200 Subject: [PATCH] update examples --- docs/resources/assistant.md | 40 ++++++++++++++++--- docs/resources/file.md | 16 +++++++- docs/resources/vector_store.md | 23 ++++++++++- .../resources/openai_assistant/resource.tf | 40 ++++++++++++++++--- examples/resources/openai_file/resource.tf | 11 +++++ .../resources/openai_vector_store/resource.tf | 18 +++++++++ 6 files changed, 134 insertions(+), 14 deletions(-) create mode 100644 examples/resources/openai_file/resource.tf create mode 100644 examples/resources/openai_vector_store/resource.tf diff --git a/docs/resources/assistant.md b/docs/resources/assistant.md index 7d2924b..7b2155c 100644 --- a/docs/resources/assistant.md +++ b/docs/resources/assistant.md @@ -21,16 +21,44 @@ terraform { } } +# resource "openai_assistant" "test" { +# name = "tf-test-sample" +# description = "tf-test-sample" +# model = "gpt-4" +# instructions = "You are a personal math tutor. When asked a question, write and run Python code to answer the question." +# tools = [ +# { +# type = "code_interpreter" +# } +# ] +# } + +resource "openai_file" "test" { + filepath = "./test-fixtures/test.jsonl" +} + +resource "openai_vector_store" "test" { + name = "test_vector_store" + file_ids = [ + openai_file.test.id + ] +} + resource "openai_assistant" "test" { - name = "tf-test-sample" - description = "tf-test-sample" - model = "gpt-4" + name = "test_assistant" + description = "my test assistant description" + model = "gpt-3.5-turbo" instructions = "You are a personal math tutor. When asked a question, write and run Python code to answer the question." tools = [ - { - type = "code_interpreter" - } + { type = "file_search" } ] + tool_resources = { + file_search = { + vector_store_ids = [ + openai_vector_store.test.id, + ] + } + } } ``` diff --git a/docs/resources/file.md b/docs/resources/file.md index c6d27af..3ba3e6e 100644 --- a/docs/resources/file.md +++ b/docs/resources/file.md @@ -10,7 +10,21 @@ description: |- File resource - +## Example Usage + +```terraform +terraform { + required_providers { + openai = { + source = "skyscrapr/openai" + } + } +} + +resource "openai_file" "test" { + filepath = "./test-fixtures/test.jsonl" +} +``` ## Schema diff --git a/docs/resources/vector_store.md b/docs/resources/vector_store.md index c1604e9..5f4312a 100644 --- a/docs/resources/vector_store.md +++ b/docs/resources/vector_store.md @@ -10,7 +10,28 @@ description: |- VectorStore resource - +## Example Usage + +```terraform +terraform { + required_providers { + openai = { + source = "skyscrapr/openai" + } + } +} + +resource "openai_file" "test" { + filepath = "./test-fixtures/test.jsonl" +} + +resource "openai_vector_store" "test" { + name = "test_vector_store" + file_ids = [ + openai_file.test.id + ] +} +``` ## Schema diff --git a/examples/resources/openai_assistant/resource.tf b/examples/resources/openai_assistant/resource.tf index 4822235..e644212 100644 --- a/examples/resources/openai_assistant/resource.tf +++ b/examples/resources/openai_assistant/resource.tf @@ -6,14 +6,42 @@ terraform { } } +# resource "openai_assistant" "test" { +# name = "tf-test-sample" +# description = "tf-test-sample" +# model = "gpt-4" +# instructions = "You are a personal math tutor. When asked a question, write and run Python code to answer the question." +# tools = [ +# { +# type = "code_interpreter" +# } +# ] +# } + +resource "openai_file" "test" { + filepath = "./test-fixtures/test.jsonl" +} + +resource "openai_vector_store" "test" { + name = "test_vector_store" + file_ids = [ + openai_file.test.id + ] +} + resource "openai_assistant" "test" { - name = "tf-test-sample" - description = "tf-test-sample" - model = "gpt-4" + name = "test_assistant" + description = "my test assistant description" + model = "gpt-3.5-turbo" instructions = "You are a personal math tutor. When asked a question, write and run Python code to answer the question." tools = [ - { - type = "code_interpreter" - } + { type = "file_search" } ] + tool_resources = { + file_search = { + vector_store_ids = [ + openai_vector_store.test.id, + ] + } + } } \ No newline at end of file diff --git a/examples/resources/openai_file/resource.tf b/examples/resources/openai_file/resource.tf new file mode 100644 index 0000000..63ae5b6 --- /dev/null +++ b/examples/resources/openai_file/resource.tf @@ -0,0 +1,11 @@ +terraform { + required_providers { + openai = { + source = "skyscrapr/openai" + } + } +} + +resource "openai_file" "test" { + filepath = "./test-fixtures/test.jsonl" +} diff --git a/examples/resources/openai_vector_store/resource.tf b/examples/resources/openai_vector_store/resource.tf new file mode 100644 index 0000000..b1e8836 --- /dev/null +++ b/examples/resources/openai_vector_store/resource.tf @@ -0,0 +1,18 @@ +terraform { + required_providers { + openai = { + source = "skyscrapr/openai" + } + } +} + +resource "openai_file" "test" { + filepath = "./test-fixtures/test.jsonl" +} + +resource "openai_vector_store" "test" { + name = "test_vector_store" + file_ids = [ + openai_file.test.id + ] +}