Skip to content

Commit

Permalink
Fetch ranker relevance scores from GraphQL (#5066)
Browse files Browse the repository at this point in the history
Use https://github.com/sourcegraph/sourcegraph/pull/64172 in Cody

## Test plan

- tested locally
- code behind a feature flag
  • Loading branch information
rafax authored Jul 31, 2024
1 parent d5c6c1f commit a81c35a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/shared/src/sourcegraph-api/graphql/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ type RecordContextResponse = unknown
interface RankContextResponse {
rankContext: {
ranker: string
used: number[]
ignored: number[]
used: { index: number; score: number }[]
ignored: { index: number; score: number }[]
}
}

Expand Down
10 changes: 8 additions & 2 deletions lib/shared/src/sourcegraph-api/graphql/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,14 @@ export const RANK_CONTEXT_QUERY = `
query RankContext($interactionId: String!, $query: String!, $contextItems: [InputContextItem!]!) {
rankContext(interactionId: $interactionId, query:$query, contextItems: $contextItems) {
ranker
used
ignored
used {
index
score
}
ignored {
index
score
}
}
}`

Expand Down
6 changes: 5 additions & 1 deletion vscode/src/chat/context/contextAPIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ function toInput(input: ContextItem[]): InputContextItem[] {
retriever: i.source || '',
}
)
.filter(i => i !== null) as InputContextItem[]
.filter(notNull)
}

function notNull<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined
}

export class ContextAPIClient {
Expand Down

0 comments on commit a81c35a

Please sign in to comment.