Skip to content
The Chat Archive
claude-1· Anthropic Arena Human Preference 55K

Using Kotlin and Unirest implement a function fun getGithubIssue(owner:String,…

  1. User

    Using Kotlin and Unirest implement a function fun getGithubIssue(owner:String, repo:String, number:Int):GithubIssue. It only needs to return the fields number, title, body

  2. Assistant

    Here is a Kotlin function to get a GitHub issue using Unirest:

    fun getGithubIssue(owner:String, repo:String, number:Int): GithubIssue {
        val url = "https://api.github.com/repos/$owner/$repo/issues/$number"
        val response = Unirest.get(url)
            .header("Accept", "application/vnd.github.v3+json")
            .asJson()
    
        val issue = GithubIssue(
            number = response.body.obj.`number` as Int,
            title = response.body.obj.title as String,
            body = response.body.obj.body as String
        )
        return issue
    }
    
    data class GithubIssue(val number: Int, val title: String, val body: String) 
    

    This function:

    • Constructs the API URL for the issue
    • Makes a GET request to the GitHub API using Unirest
    • Parses the JSON response and extracts the issue number, title and body
    • Returns a GithubIssue data class with those fields

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.