codeshackio / multi-select-dropdown-js

Customizable Multi Select Dropdown built with HTML and JavaScript, featuring search, select-all, and dynamic options without dependencies.
MIT License
7 stars 1 forks source link

Designapp #1

Closed Hak36Khay closed 2 days ago

Hak36Khay commented 4 weeks ago

new MultiSelect(document.getElementById('example-multi-select'), { data: [ { value: 'opt1', text: 'Option 1' }, { value: 'opt2', html: 'Option 2 with HTML!' }, { value: 'opt3', text: 'Option 3', selected: true }, { value: 'opt4', text: 'Option 4' }, { value: 'opt5', text: 'Option 5' } ], placeholder: 'Select options', max: 5, // Maximum number of items that can be selected search: true, // Enable the search box selectAll: true, // Add a select all option onChange: function(value, text, element) { console.log('Change:', value, text, element); }, onSelect: function(value, text, element) { console.log('Selected:', value, text, element); }, onUnselect: function(value, text, element) { console.log('Unselected:', value, text, element); } });

Hak36Khay commented 4 weeks ago

// Add dependencies in your build.gradle file dependencies { implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' }

// Create a service interface for OpenAI API public interface OpenAIService { @POST("v1/engines/davinci-codex/completions") Call getResponse(@Body OpenAIRequest request); }

// Create a model class for the request public class OpenAIRequest { private String prompt; private int max_tokens;

public OpenAIRequest(String prompt, int max_tokens) {
    this.prompt = prompt;
    this.max_tokens = max_tokens;
}

}

// Create a model class for the response public class OpenAIResponse { private List choices;

public List<Choice> getChoices() {
    return choices;
}

public class Choice {
    private String text;

    public String getText() {
        return text;
    }
}

}

// Make the API call and handle the response Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.openai.com/") .addConverterFactory(GsonConverterFactory.create()) .build();

OpenAIService service = retrofit.create(OpenAIService.class); OpenAIRequest request = new OpenAIRequest("Hello, how can I help you?", 50);

service.getResponse(request).enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { String reply = response.body().getChoices().get(0).getText(); // Display the reply in the chat interface } }

@Override
public void onFailure(Call<OpenAIResponse> call, Throwable t) {
    // Handle the error
}

});

codeshackio commented 1 week ago

Can you provide more context regarding your issue?