in

Crafting a Top-Tier ChatGPT Plugin for Medium | by Thomas Ricouard | Apr, 2023



Exploring the Technical Capabilities of ChatGPT Plugins

OpenAI has made a groundbreaking announcement for its chatbot, ChatGPT – plugin support. Plugins provide access to content platforms, such as Medium, which were previously inaccessible to ChatGPT due to its limitations. This article delves into the technical side of the concept, discussing the development process, how the plugin works, and its capabilities.

Building and Exposing ChatGPT Plugins

Building a plugin for ChatGPT is relatively simple. You need to expose a “.well-known/ai-plugin.json” file on your domain, which provides the necessary information for ChatGPT to recognize your domain as a supported plugin – including its description, link, and icons. The most critical part of this process is the OpenAPI YAML file that you provide. This file allows ChatGPT to comprehend your API, its functions, and its triggers.

To build the YAML file, you can export it from a server interface in various languages, such as Go – which Medium used for this proof of concept – or write it from scratch using the OpenAPI specification. Once the YAML file is developed, ChatGPT can understand your API and its triggers.

Medium’s Go-based Middleware

Medium developed a simple middleware in Go for its ChatGPT plugin, which converts hardcoded GraphQL queries into a standard REST API that ChatGPT can understand. This middleware takes limited components of an internal API and exposes them as a REST API that ChatGPT can use. For instance, one function that serves trending posts is defined in Medium’s bridge function as below:

“`type Post struct {
ID string `json:”id”`
Title string `json:”title”`
// … More Post object fields
}
func (a *App) Trending(ctx context.Context) ([]*model.Post, error) {
req := graphql.NewRequest(`query trending {… GQL Query}`)
var respData struct {
Trending struct {
Posts []*model.Post `json:”posts”`
} `json:”trending”`
}
if err := a.client.Run(ctx, req, &respData); err != nil {
return nil, errors.Wrap(err, “fetching trending from rito”)
}
return respData.Trending.Posts, nil
}“`

The endpoint for this trend lookup is available in OpenAPI specification, allowing ChatGPT to understand what this plugin can do, what API to activate and when exactly.

Debugging and Testing ChatGPT Plugins

Medium tested its plugin by debugging directly on the ChatGPT platform. Firstly, they verified the ChatGPT’s understanding of the API surface itself, ensuring it is in line with their API’s functionality, and updated the documentation, if necessary. They also tested the platform’s capability to trigger the Medium plugin, queried the latest and trending posts, and tested it for post content. Next, they tested for related posts. Lastly, they queried for opinion and summary of a heated tech debate and managed to fetch a relevant post in response.

Concluding Thoughts

The development and deployment of ChatGPT plugins present opportunities to streamline and expand conversations with chatbots, providing access to a vast amount of information on content platforms. With our technical exploration, we demonstrated the ease of building and exposing ChatGPT plugins and the variety of functions they can perform.



Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

“Mastering Taste: Insights from Legendary Producer Rick Rubin”

Crafting High-Performance AI Product Moats Using Generative AI – Jay Alammar – Simplifying Machine Learning one Concept at a time.