Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

RFC 969 API boilerplate#63789

Merged
rafax merged 17 commits into
mainfrom
rg/rfc-969-api-boilerplate
Jul 15, 2024
Merged

RFC 969 API boilerplate#63789
rafax merged 17 commits into
mainfrom
rg/rfc-969-api-boilerplate

Conversation

@rafax

@rafax rafax commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

This PR adds experimental endpoints implementing for context ranking and storage, as required by RFC 969.
Also removes the deprecated and unused getCodyIntent query (we have chatIntent).

Test plan

  • tested locally, not integrated with any clients

@cla-bot cla-bot Bot added the cla-signed label Jul 11, 2024
@rafax rafax requested a review from janhartman July 11, 2024 20:37
@rafax rafax requested a review from a team July 12, 2024 10:37
@rafax rafax marked this pull request as ready for review July 12, 2024 10:37

@janhartman janhartman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

"""
Optional: Name of the file associated with this context item.
"""
fileName: String

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also add ranges within the file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth on this - I don't want to mirror the whole "FileBasedContextItem" structure here (and the same thing for OpenCtx / URL / ...) so this API is easy to use, so I agree we should either remove fileName or add line ranges. WDYT - should we drop fileName for now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please leave it in and add ranges as well? It will be really helpful for constructing datasets from logs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, added.

Comment thread cmd/frontend/graphqlbackend/cody_context.graphql
GetCodyIntent(ctx context.Context, args GetIntentArgs) (IntentResolver, error)
ChatIntent(ctx context.Context, args ChatIntentArgs) (IntentResolver, error)
RankContext(ctx context.Context, args RankContextArgs) (RankContextResolver, error)
RecordContext(ctx context.Context, args RecordContextArgs) (*EmptyResponse, error)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want a separate call for recording context?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because (in our current end-to-end implementation) the final decision to include a certain item is made on the client (ex. based on token limits), so it's possible that the context passed to the LLM is different from what was passed to/return from the ranking RPC. Does that make sense?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that makes sense. I guess we'll deprecate it in the future.

Comment thread cmd/frontend/graphqlbackend/cody_context.go Outdated
TargetContextWindowTokens *int32
Intent *string
Command *string
InteractionID string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query shouldn't be optional. TargetModel probably as well, but we can use a default one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today, target model is actually configured server-side (for chat), so it felt natural not to require the client to pass it (ex. it's not required if you call the actual Completions endpoint).

Over time, I expect most of the optional fields to become required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for Query - we can look it up on the server using InteractionId, do you think we should require the client to pass it again?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why would we want extra look ups? IMO passing it again is probably preferable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, guess it's not too hard for the client to hold on to it

@rafax rafax enabled auto-merge (squash) July 15, 2024 16:14
@rafax rafax merged commit c1efb92 into main Jul 15, 2024
@rafax rafax deleted the rg/rfc-969-api-boilerplate branch July 15, 2024 16:25
rafax referenced this pull request in sourcegraph/cody-public-snapshot Jul 18, 2024
This PR adds the Client-side integration of
https://github.com/sourcegraph/sourcegraph/pull/63789 for VSCode:
- GraphQL queries, types and client methods
- ContextAPIClient class mapping VSCode objects to GraphQL
- wiring of ContextAPIClient to existing code

Currently, for all added backend calls:

- all remote RPC are guarded by a feature flag
- results of RPCs are not used by integrating call
- calls are not awaited (to avoid slowing down interactions)

Related to AI-128.

## Test plan

- tested locally -> works with local and sourcegraph.com backend
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants