gpt-3.5-turbo-0613· OpenAI Arena Human Preference 55K
Using Kotlin and Unirest implement a function fun getGithubIssue(owner:String,…
- User
Using Kotlin and Unirest implement a function
fun getGithubIssue(owner:String, repo:String, number:Int):GithubIssue. It only needs to return the fieldsnumber, title, body - Assistant
Sure! Here's an example implementation of the
getGithubIssuefunction using Kotlin and Unirest:import com.mashape.unirest.http.Unirest import com.mashape.unirest.http.exceptions.UnirestException data class GithubIssue(val number: Int, val title: String, val body: String) fun getGithubIssue(owner: String, repo: String, number: Int): GithubIssue { try { val response = Unirest.get("https://api.github.com/repos/$owner/$repo/issues/$number") .header("Accept", "application/vnd.github.v3+json") .asJson() val issueJson = response.body.`object` val issueNumber = issueJson.getInt("number") val issueTitle = issueJson.getString("title") val issueBody = issueJson.getString("body") return GithubIssue(issueNumber, issueTitle, issueBody) } catch (e: UnirestException) { throw RuntimeException("Failed to fetch GitHub issue", e) } } fun main() { val owner = "your-github-owner" val repo = "your-github-repo" val issueNumber = 123 val issue = getGithubIssue(owner, repo, issueNumber) println("Issue Number: ${issue.number}") println("Issue Title: ${issue.title}") println("Issue Body: ${issue.body}") }Make sure you have the Unirest library added to your project dependencies. This implementation will fetch the issue details from the GitHub API and return a
GithubIssuedata class with thenumber,title, andbodyfields. You can then use themainfunction to test thegetGithubIssuefunction by providing your own GitHub owner, repo, and issue number.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.