Skip to content

Commit

Permalink
feature: providerlog context is no longer a json
Browse files Browse the repository at this point in the history
We think it's better if context is just a string with the full
conversation excluding the response.
  • Loading branch information
geclos committed Sep 30, 2024
1 parent b29a724 commit c5b0aa8
Show file tree
Hide file tree
Showing 6 changed files with 463 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function EvaluationList({
onSearchChange,
}: EvaluationListProps) {
return (
<div className='w-1/2'>
<div className='w-1/2 max-h-[520px] overflow-y-auto'>
<Input
type='text'
placeholder='Search evaluations and templates...'
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ProviderApiKey } from './browser'

export function objectToString(object: any) {
try {
return JSON.stringify(object)
return JSON.stringify(object, null, 2)
} catch (error) {
return 'Error: Provider returned an object that could not be stringified'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ describe('DocumentVersionsRepository', () => {

const documents = result.unwrap()
expect(documents).toHaveLength(2)
const paths = documents.map((d) => d.path).sort()
expect(paths).toEqual(['bar', 'foo'])
expect(documents.map((d) => d.path).sort()).toEqual(['bar', 'foo'])
expect(new Set(documents.map((d) => d.path))).toEqual(
new Set(['foo', 'bar']),
)
expect(documents.every((d) => d.commitId === commit1Id)).toBe(true)
})

Expand Down
11 changes: 7 additions & 4 deletions packages/core/src/services/chains/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Chain, ContentType, MessageRole } from '@latitude-data/compiler'
import { v4 as uuid } from 'uuid'
import { beforeEach, describe, expect, it, vi } from 'vitest'

import { Workspace } from '../../browser'
import { objectToString, Workspace } from '../../browser'
import { LogSources, Providers } from '../../constants'
import * as factories from '../../tests/factories'
import * as aiModule from '../ai'
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('runChain', () => {
expect.objectContaining({
documentLogUuid: expect.any(String),
object: { name: 'John', age: 30 },
text: '{"name":"John","age":30}',
text: objectToString({ name: 'John', age: 30 }),
usage: { totalTokens: 15 },
}),
)
Expand Down Expand Up @@ -377,7 +377,7 @@ describe('runChain', () => {
expect.objectContaining({
documentLogUuid: expect.any(String),
object: { name: 'John', age: 30 },
text: '{"name":"John","age":30}',
text: objectToString({ name: 'John', age: 30 }),
usage: { totalTokens: 15 },
}),
)
Expand Down Expand Up @@ -463,7 +463,10 @@ describe('runChain', () => {
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 },
],
text: '[{"name":"John","age":30},{"name":"Jane","age":25}]',
text: objectToString([
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 },
]),
usage: { totalTokens: 20 },
}),
)
Expand Down
Loading

0 comments on commit c5b0aa8

Please sign in to comment.