com.alibaba.dashscope.base.HalfDuplexServiceParam Maven / Gradle / Ivy
The newest version!
// Copyright (c) Alibaba, Inc. and its affiliates.
package com.alibaba.dashscope.base;
import java.util.HashMap;
import java.util.Map;
import lombok.Builder.Default;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
/** The model service base class */
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public abstract class HalfDuplexServiceParam extends HalfDuplexParamBase {
/** The model to use. */
@lombok.NonNull private String model;
@Default private Object resources = null;
@Override
public String getModel() {
return model;
}
@Override
public Map getParameters() {
return parameters;
}
@Override
public Object getResources() {
return resources;
}
@Override
public Map getHeaders() {
Map res = new HashMap<>();
for (Map.Entry entry : headers.entrySet()) {
String key = entry.getKey();
String value = entry.getValue().toString();
res.put(key, value);
}
return res;
}
public void putHeader(String key, String value) {
if (headers.size() == 0) {
headers = new HashMap();
} else {
HashMap newHeaders = new HashMap<>();
newHeaders.putAll(headers);
headers = newHeaders;
}
headers.put(key, value);
}
}