Skip to content

Instantly share code, notes, and snippets.

@thenamankumar
Created September 5, 2024 14:33
Show Gist options
  • Save thenamankumar/fcbe2ae304ef31107a02439ee855a896 to your computer and use it in GitHub Desktop.
Save thenamankumar/fcbe2ae304ef31107a02439ee855a896 to your computer and use it in GitHub Desktop.
export default {
meta(_, _settings) {
return {
name: 'Go Code Guidelines',
annotations: {},
mentions: {
// this provider will be used to fetch default context.
autoInclude: true
}
};
},
mentions({ _query, uri, codebase, autoInclude }, _settings) {
// if this request is not to get default context items to auto include, return an empty array.
if (!autoInclude) {
return [];
}
// for all go files in cody repository
if (uri?.endsWith('.go') && codebase === 'github.com/sourcegraph/cody') {
return [
{
title: 'Go Coding Guidelines',
uri: 'https://example.com/go-guidelines.txt',
description: 'From OpenCtx'
}
];
}
return [];
},
async items({ query_, mention }, _settings) {
// the selected mention item will be received in the params.
if (!mention?.uri) {
return [];
}
// fetch the content from a webpage or an API.
const content = await fetch(mention.uri).then((res) => res.text());
// return context items to be included in prompt for the LLM.
return [
{
title: mention.title,
uri: mention.uri,
ai: {
content
}
}
];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment