-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MARP-174-Error-using-ChatGPT-assistant (#43)
- Loading branch information
1 parent
a2201fa
commit cc12f4a
Showing
11 changed files
with
191 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
openai-assistant/src/com/axonivy/connector/openai/assistant/models/Model.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.axonivy.connector.openai.assistant.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class Model { | ||
private String id; | ||
private String object; | ||
private long created; | ||
@JsonProperty("owned_by") | ||
private String ownedBy; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getObject() { | ||
return object; | ||
} | ||
|
||
public void setObject(String object) { | ||
this.object = object; | ||
} | ||
|
||
public long getCreated() { | ||
return created; | ||
} | ||
|
||
public void setCreated(long created) { | ||
this.created = created; | ||
} | ||
|
||
public String getOwnedBy() { | ||
return ownedBy; | ||
} | ||
|
||
public void setOwnedBy(String ownedBy) { | ||
this.ownedBy = ownedBy; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
openai-assistant/src/com/axonivy/connector/openai/assistant/models/ResponseModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.axonivy.connector.openai.assistant.models; | ||
|
||
import java.util.List; | ||
|
||
public class ResponseModel { | ||
private String object; | ||
private List<Model> data; | ||
|
||
public String getObject() { | ||
return object; | ||
} | ||
|
||
public void setObject(String object) { | ||
this.object = object; | ||
} | ||
|
||
public List<Model> getData() { | ||
return data; | ||
} | ||
|
||
public void setData(List<Model> data) { | ||
this.data = data; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
openai-assistant/src/com/axonivy/connector/openai/assistant/ui/SelectModelDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.axonivy.connector.openai.assistant.ui; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.jface.dialogs.IDialogConstants; | ||
import org.eclipse.jface.dialogs.MessageDialog; | ||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.widgets.Combo; | ||
import org.eclipse.swt.widgets.Composite; | ||
import org.eclipse.swt.widgets.Control; | ||
import org.eclipse.swt.widgets.Shell; | ||
|
||
public class SelectModelDialog extends MessageDialog { | ||
|
||
private String value; | ||
private Combo comboField; | ||
private List<String> models; | ||
|
||
public SelectModelDialog(Shell parent, String message, String title, String value, List<String> models) { | ||
super(parent, title, null, message, MessageDialog.CONFIRM, | ||
new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); | ||
this.value = value; | ||
this.models = models; | ||
} | ||
|
||
@Override | ||
protected Control createCustomArea(Composite parent) { | ||
comboField = new Combo(parent, SWT.READ_ONLY); | ||
String items[] = models.toArray(new String[0]); | ||
comboField.setItems(items); | ||
int defaultModelIndex = models.indexOf(value); | ||
comboField.select(defaultModelIndex); | ||
return comboField; | ||
} | ||
|
||
@Override | ||
protected void buttonPressed(int buttonId) { | ||
if (buttonId == 0) { | ||
value = comboField.getText(); | ||
} else { | ||
value = null; | ||
} | ||
super.buttonPressed(buttonId); | ||
} | ||
|
||
public static String open(Shell parent, String title, String message, String value, List<String> models) { | ||
var modelDialog = new SelectModelDialog(parent, message, title, value, models); | ||
String[] result = new String[1]; | ||
parent.getDisplay().syncExec(() -> { | ||
modelDialog.open(); | ||
result[0] = modelDialog.getValue(); | ||
}); | ||
return result[0]; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
} |