Skip to content

Commit

Permalink
feat: Update feedback to v2 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
viveknair committed Dec 5, 2023
1 parent 2b33887 commit a8a617a
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 179 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"build": "run-s sconfig generate",
"build-py": "run-s sconfig generate:python",
"build-node": "run-s sconfig generate:node-ts",
"build-browser": "run-s sconfig generate:browser",
"build-browser": "run-s sconfig generate:browser-ts",
"clean": "rimraf dist",
"bump-patch": "./scripts/bump-patch",
"sconfig": "run-s sconfig:spec-version sconfig:create-custom-specs",
Expand Down
5 changes: 2 additions & 3 deletions scripts/create-custom-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ const feedbackSpec = yaml.load(
fs.readFileSync(RESOLVED_SPEC_LOCATION, "utf8")
) as OpenAPISpec;

const feedbackTag = "Feedback";
const feedbackPaths = Object.fromEntries(
Object.entries(feedbackSpec.paths).filter(([, data]) =>
Object.values(data).some((op) => op.tags && op.tags.includes(feedbackTag))
Object.entries(feedbackSpec.paths).filter(([endpoint, data]) =>
endpoint.includes("/feedback")
)
);

Expand Down
325 changes: 154 additions & 171 deletions spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,143 +45,11 @@ paths:
description: Bad request
"500":
description: Internal server error
x-gentraceMeta:
name: Store Run event
group: Core
path: run
examples:
curl: |
curl -X POST \
-H 'Authorization: Bearer gen_api_NkztHpkHvl5Z8CXIHZJq3bFPHwO4eLj2dtkh9HGt' \
-H 'Content-Type: application/json' \
-d '{
"name": "write-email",
"stepRuns": [
{
"provider": {
"name": "openai",
"invocation": "openai_createCompletion",
"modelParams": {
"promptTemplate": "What'\''s {{ interestingFact }} in {{ location }}?"
},
"inputs": {
"prompt": {
"interestingFact": "the trendiest neighborhood",
"location": "New York City"
}
},
"outputs": {
"choices": [
{
"text": "Williamsburg is the trendiest neighborhood in New York City."
}
]
}
},
"elapsedTime": 348,
"startTime": "2023-03-23T21:16:37.188Z",
"endTime": "2023-03-23T21:16:37.896Z"
},
{
"provider": {
"name": "openai",
"invocation": "openai_createCompletion",
"modelParams": {
"promptTemplate": "Expand upon the provided paragraph: \\n\\n {{ locationFact }}"
},
"inputs": {
"prompt": {
"locationFact": "The trendiest neighborhood in NYC is Williamsburg."
}
},
"outputs": {
"choices": [
{
"text": "Williamsburg is a neighborhood located in the Brooklyn borough of New York City, and it has become one of the trendiest neighborhoods in the city over the past decade. Known for its artsy vibe, vintage shops, street art, and creative atmosphere, Williamsburg has attracted a young, hip crowd that has helped to transform the neighborhood into a hub for music, fashion, and nightlife."
}
]
}
},
"elapsedTime": 562,
"startTime": "2023-03-23T21:16:38.248Z",
"endTime": "2023-03-23T21:16:38.556Z"
}
]
}' \
https://gentrace.ai/api/v1/run

node.js: |
const { Configuration, Gentrace } = require("@gentrace/node");
const configuration = new Configuration({
apiKey: process.env.GENTRACE_API_KEY,
});
const gentrace = new Gentrace(configuration);
gentrace.run({
name: "write-email",
stepRuns: [
{
provider: {
name: "openai",
invocation: "openai_createCompletion",
modelParams: {
promptTemplate: "What's {{ interestingFact }} in {{ location }}?"
},
inputs: {
prompt: {
interestingFact: "the trendiest neighborhood",
location: "New York City"
}
},
outputs: {
choices: [
{
text: "Williamsburg is the trendiest neighborhood in New York City."
}
]
}
},
elapsedTime: 348,
startTime: "2023-03-23T21:16:37.188Z",
endTime: "2023-03-23T21:16:37.896Z"
},
{
provider: {
name: "openai",
invocation: "openai_createCompletion",
modelParams: {
promptTemplate: "Expand upon the provided paragraph: \n\n {{ locationFact }}"
},
inputs: {
prompt: {
locationFact: "The trendiest neighborhood in NYC is Williamsburg."
}
},
outputs: {
choices: [
{
text: "Williamsburg is a neighborhood located in the Brooklyn borough of New York City, and it has become one of the trendiest neighborhoods in the city over the past decade. Known for its artsy vibe, vintage shops, street art, and creative atmosphere, Williamsburg has attracted a young, hip crowd that has helped to transform the neighborhood into a hub for music, fashion, and nightlife."
}
]
}
},
elapsedTime: 562,
startTime: "2023-03-23T21:16:38.248Z",
endTime: "2023-03-23T21:16:38.556Z"
}
]
});
response: |
{
"pipelineRunId": "13448D47-BD5D-4664-B6C3-0CB07D8CF2D2"
}
/v1/feedback:
post:
tags:
- Feedback
- v1
summary: Submit feedback
requestBody:
required: true
Expand All @@ -204,44 +72,6 @@ paths:
"500":
description: Server error

x-gentraceMeta:
name: Store feedback event
group: core
path: feedback
examples:
curl: |
curl -X POST \
-H 'Authorization: Bearer gen_api_NkztHpkHvl5Z8CXIHZJq3bFPHwO4eLj2dtkh9HGt' \
-H 'Content-Type: application/json' \
-d '{
"pipelineRunId": "cc22e63c-1c9a-4cbb-a8ee-7f764eabf97d",
"rating": "positive",
"recordedTime": "2023-03-31T15:00:00.000Z",
"details": "This generated output communicated my voice wonderfully!"
}' \
https://gentrace.ai/api/v1/feedback
node.js: |
const { Configuration, Gentrace } = require("@gentrace/node");
const configuration = new Configuration({
apiKey: process.env.GENTRACE_API_KEY,
});
const gentrace = new Gentrace(configuration);
gentrace.feedback({
pipelineRunId: "cc22e63c-1c9a-4cbb-a8ee-7f764eabf97d",
rating: "positive",
recordedTime: "2023-03-31T15:00:00.000Z",
details: "This generated output communicated my voice wonderfully!"
});
response: |
{
"pipelineRunId": "13448D47-BD5D-4664-B6C3-0CB07D8CF2D2"
}
/v1/test-case:
get:
tags:
Expand Down Expand Up @@ -807,6 +637,91 @@ paths:
message:
type: string

/v2/feedback:
post:
tags:
- v2
summary: Create feedback
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreateFeedbackV2"
responses:
"200":
description: Feedback created successfully
content:
application/json:
schema:
$ref: "#/components/schemas/FeedbackV2"
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/FeedbackV2"
"400":
description: Bad request
"500":
description: Server error

/v2/feedback/{id}:
get:
tags:
- v2
summary: Get feedback
parameters:
- in: path
name: id
required: true
schema:
type: string
format: uuid
description: Feedback ID
responses:
"200":
description: Feedback retrieved successfully
content:
application/json:
schema:
$ref: "#/components/schemas/FeedbackV2"
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/FeedbackV2"
"404":
description: Feedback not found

patch:
tags:
- v2
summary: Update feedback
parameters:
- in: path
name: id
required: true
schema:
type: string
format: uuid
description: Feedback ID
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/UpdateFeedbackV2"
responses:
"200":
description: Feedback updated successfully
content:
application/json:
schema:
$ref: "#/components/schemas/FeedbackV2"
application/json; charset=utf-8:
schema:
$ref: "#/components/schemas/FeedbackV2"
"400":
description: Bad request
"500":
description: Server error

/v2/test-results:
get:
tags:
Expand Down Expand Up @@ -1148,6 +1063,74 @@ components:
type: string
additionalProperties: true


CreateFeedbackV2:
type: object
properties:
pipelineRunId:
type: string
format: uuid
description: The unique identifier for the pipeline run
recordedTime:
$ref: '#/components/schemas/UnixSeconds'
score:
type: number
format: double
minimum: 0
maximum: 1
description: The score of the feedback, ranging from 0 to 1
details:
type: string
nullable: true
description: Optional details about the feedback
required:
- pipelineRunId
- recordedTime
- score

UpdateFeedbackV2:
type: object
properties:
score:
type: number
format: double
minimum: 0
maximum: 1
description: The score of the feedback, ranging from 0 to 1
details:
type: string
nullable: true
description: Optional details about the feedback

FeedbackV2:
type: object
properties:
id:
type: string
format: uuid
description: The unique identifier for the feedback
pipelineRunId:
type: string
format: uuid
description: The unique identifier for the pipeline run
score:
type: number
format: double
minimum: 0
maximum: 1
description: The score of the feedback, ranging from 0 to 1
details:
type: string
nullable: true
description: Optional details about the feedback
recordedTime:
$ref: '#/components/schemas/UnixSeconds'
required:
- id
- pipelineRunId
- score
- recordedTime

ExpandedTestResult:
allOf:
- $ref: '#/components/schemas/TestResult'
Expand Down
4 changes: 0 additions & 4 deletions templates/browser/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
/* eslint-disable */
{{>licenseInfo}}

{{! Edited by Gentrace, line 6 }}
const packageJson = require("../package.json");

export interface ConfigurationParameters {
clientToken?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
Expand Down Expand Up @@ -80,7 +77,6 @@ export class Configuration {
this.baseOptions = {};
}
this.baseOptions.headers = {
'User-Agent': `OpenAI/NodeJS/${packageJson.version}`,
'Authorization': `Bearer ${this.clientToken}`,
...this.baseOptions.headers,
}
Expand Down

0 comments on commit a8a617a

Please sign in to comment.