Skip to content

Commit

Permalink
added spec
Browse files Browse the repository at this point in the history
  • Loading branch information
shohey1226 committed Jul 2, 2023
1 parent e8ba82d commit 68c67a9
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/llm_memory/broca.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def respond_with_schema(context: {}, schema: {})
begin
response = client.chat(
parameters: {
model: @model,
model: "gpt-3.5-turbo-0613", # as of July 3, 2023
messages: [
{
role: "user",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions spec/llm_memory/broca_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,24 @@
res = broca.respond(related_docs: related_docs, query_str: "what is my name?")
expect(res).to include("Shohei")
end

it "runs respond_with_schema method", :vcr do
related_docs = [{content: "My name is Shohei"}, {content: "I'm a software engineer"}]
broca = LlmMemory::Broca.new(prompt: template)
res = broca.respond_with_schema(
context: {related_docs: related_docs, query_str: "what is my name?"},
schema: {
type: :object,
properties: {
name: {
type: :string,
description: "The name of person"
}
},
required: ["name"]
}
)
expect(res).to include({name: "Shohei"})
end
end
end

0 comments on commit 68c67a9

Please sign in to comment.